1. 在 Eclipse 中新一个 maven 工程。
2. 修改 pom.xml 文件添加如下内容:
3.
????????
????????spring-boot-starter-parent
????????
????
????
????????
????????????
????????????spring-boot-starter-web
????????
????????
????????
???????? spring-boot-starter-actuator
????????
????????
????????
???????? spring-boot-starter-test
????????
????????
????
????
????????
????
true
????????
????????????
????????????????
????????????????spring-boot-maven-plugin
????????????
????????
????
import?org.springframework.boot.SpringApplication;
import?org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public?class?Application?{
public?static?void?main(String[]?args)?{
SpringApplication.run(Application.class,?args);
}
}5. 添加 HelloController 类:
import?org.springframework.web.bind.annotation.RequestMapping;
import?org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/hello")
public?class?HelloController?{
@RequestMapping("/welcome")
public?String?welcome()?{
return?"Hello?World!";
}
}然后运行。
搜一下:一个最简单的 spring boot restful 例子。