1、新建maven项目
2、pom.xml 里添加SpringBoot所依赖的jar包
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.3.3.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
保存后、自动下载这一系列的相关的jar包(太多的无法完全截图)
3、在src/main/java 目录下新建package com.st.controller
4、在 controller 中新建
TestController.java
package com.st.controller; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @EnableAutoConfiguration public class TestController { @RequestMapping("/hello") //访问地址http://localhost:8080/hello public String hello(){ return "success"; } public static void main(String[] args) { //运行 SpringApplication.run(TestController.class, args); } }