初学spring,开启注释扫描时就报这个错误,网上寻找一番大概是JDK和Spring版本不对应。开始我是用spring5.0.0版本不行,然后5.2.0版本还是不行。
然后在spring项目中找到了对应的版本,JDK17要用5.3.0以上的了
https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-Versions
这是spring的下载地址https://mvnrepository.com/artifact/org.springframework/spring-beans
导入idea时的要用的依赖
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.18</version>
</dependency>
<!--https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.18</version>
</dependency>
<!--https://mvnrepository.com/artifact/org.springframework/spring-beans -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.3.18</version>
</dependency>