01 - Getting Started

02 - Introduction To Web Services
001 Introduction To Web Services - An Overview





如何让不同语言或不同服务之间通信

有两个服务



使用固定格式通信,与平台无关,实现跨语言和系统的通信
主流有 json 和 xml 的通信格式




004 Web Services - Key Terminology







005 Introduction to SOAP Web Services








006 Introduction to RESTful Web Services



007 SOAP vs RESTful Web Services

03 - Introduction to Spring Framework in 10 Steps (NOW 16)
001 Step 01 - Getting Started with Spring Framework - Goals



003 Step 02 - Setting up New Spring Project with Spring Initializr
不要使用 snapshot 版本

004 Step 03 - Iteration 1 - Building Tightly Coupled GameRunner and MarioGame

package org.malred.learnspringframework;
import org.malred.learnspringframework.game.GameRunner;
import org.malred.learnspringframework.game.MarioGame;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class LearnSpringFrameworkApplication {
// 用vscode拓展和mvn org.springframework.boot:spring-boot-maven-plugin:2.6.3:run运行成功
// mvn springboot:run 失败
public static void main(String[] args) {
// SpringApplication.run(LearnSpringFrameworkApplication.class, args);
MarioGame game = new MarioGame();
GameRunner runner = new GameRunner(game);
runner.run();
}
}
package org.malred.learnspringframework.game;
public class MarioGame {
public void up() {
System.out.println("up");
}
public void down() {
System.out.println("down");
}
public void left() {
System.out.println("left");
}
public void right() {
System.out.println("right");
}
}
package org.malred.learnspringframework.game;
public class GameRunner {
private MarioGame game;
public GameRunner(MarioGame game) {
this.game = game;
}
public void run() {
game.up();
game.down();
game.left();
game.right();
}
}
005 Step 04 - Understanding Tight Coupling

新创建一个 SuperContraGame 类,发现当要切换为 SuperContraGame 时,需要修改很多地方(GameRunner 的构造器、实例化的 game 类)
package org.malred.learnspringframework.game;
public class SuperContraGame {
public void up() {
System.out.println("SuperContraGame up");
}
public void down() {
System.out.println("SuperContraGame down");
}
public void left() {
System.out.println("SuperContraGame left");
}
public void right() {
System.out.println("SuperContraGame right");
}
}
006 Step 05 - Iteration 2 - Loose Coupling Level 1 - Interfaces

通过接口减少耦合
package com.example.demo.game;
public interface GamingConsole {
void up();
void down();
void left();
void right();
}
package com.example.demo.game;
public class SuperContraGame implements GamingConsole {
public void up() {
System.out.println("up");
}
public void down() {
System.out.println("down");
}
public void left() {
System.out.println("left");
}
public void right() {
System.out.println("right");
}
}
package com.example.demo;
import com.example.demo.game.GameRunner;
import com.example.demo.game.MarioGame;
import com.example.demo.game.SuperContraGame;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
// MarioGame game = new MarioGame();
SuperContraGame game = new SuperContraGame();
GameRunner runner = new GameRunner(game);
runner.run();
}
}
