springboot单元测试:java.lang.NoClassDefFoundError: org/springframework/core/annotation/MergedAnnotations$SearchStrategy


https://www.it610.com/article/1295998852888862720.htm

springboot 单元测试启动时报错,抛出如下异常:

java.lang.NoClassDefFoundError: org/springframework/core/annotation/MergedAnnotations$SearchStrategy 

无法加载到注解包,后来怀疑是测试依赖引错了
原来的依赖是

<dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>5.2.1.RELEASE</version> </dependency> 

这是spring框架的单元自测依赖,不适用springboot的单元自测,将依赖改成如下依赖即可:

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency>


免责声明!

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



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