Spring——Cannot load configuration class: com.spring.five.config.SpringConfiguration.class


Spring注解类问题

用@Configuration配置注解类时:

@Configuration
@ComponentScan("com.spring.five")
public class SpringConfiguration {

}

ApplicationContext context=new AnnotationConfigApplicationContext(SpringConfiguration.class)运行时出错:

解决方法

    我的JDK版本是1.16,org.springframework.spring-context版本:5.0.2.RELEASE。问题产生的原因是JDK版本太高,与低版本的Spring冲突。

解决方法1:降低JDK版本,降成1.8

解决方法2:引入高版本的Spring

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>5.2.9.RELEASE</version>
</dependency>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM