解决办法:
1. 在pom.xml中必须添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
2.启动类上必须添加注解@Controller
3.启动类上必须添加注解@EnableAutoConfiguration 和 @SpringBootApplication