一、导入依赖
新建一个Maven项目,导入SpringBoot的父工程和web项目的依赖
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
二、创建一个项目的启动类
@SpringBootApplication
public class HelloApplication {
public static void main(String[] args) {
SpringApplication.run(HelloApplication.class,args);
}
}
三、创建控制层
//@RestController = @ResponseBody + @Controller
@RestController
public class HelloController {
//请求路径
@RequestMapping("/hello")
public String hello(){
return "hello spring boot";
}
}