web之家  

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>
posted on 2020-09-17 11:48  路修远而求索  阅读(4168)  评论(0编辑  收藏  举报