1、pom.xml中要加入web模块
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
2、@RestController无法识别需要引入下边两个包
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
3、pom.xml中要加入spring-web模块,否则org.springframework.web无法识别
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
4、Application的主类需要在最上层来管理其他类,否则无法启动成功。