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>
原文地址:https://www.cnblogs.com/keyi/p/13684286.html