当两个依赖同时存在时,或者只引入spring-boot-starter-web,程序运行正常
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.5.2</version> </dependency> <dependency> <groupId>org.openjdk.jol</groupId> <artifactId>jol-core</artifactId> <version>0.16</version> </dependency></dependencies>当剔除jol-core依赖时,报错如下;
java: 程序包org.springframework.beans.factory.annotation不存在解决方法:重新引入spring-boot-starter-web依赖即可
结论:jol-core引入会改变(可能是覆盖)spring-boot-starter-web的某些文件,导致错误发生