我这次出现的问题是在自己创建的全新的SpringBoot项目中的.java文件中的@RestController注解无法识别报错。
解决办法:
在pom.xml文件里面添加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
我只添加了第一个后就更新了maven,用maven reimport 更新下依赖包,如下图:

本文介绍了解决SpringBoot项目中@RestController注解无法被识别的问题。通过在pom.xml文件中添加spring-boot-starter依赖,成功解决了这个问题。
1万+





