项目中先出现了 无法访问org.springframework.web.bind.annotation.RequestMapping 的报错,在修复了这个bug之后,又出现了无法访问org.springframework.boot.SpringApplication的报错。
@RequestMapping 和 @SpringBootApplication 都是SpringBoot项目所带的注解,当一个无法识别可以检查以下依赖配置,如果两个都报错那可能是JDK版本和依赖的版本不匹配的问题
到pom.xml配置文件中找到如下代码,将<version>中的版本号降低
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.10</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>