JAVA 编写测试类出现的问题(三)java.lang.NoClassDefFoundError: org/springframework/core/annotation/MergedAnnotati


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

出现这个问题,找到此路径下的这个包发现都没有这个类。

实际上是我们引入的包的版本不对导致的。以上是我采用的pom包,当然有一些冗余,甄别自己的需要的去引用

   

        
            org.springframework.boot
            spring-boot-starter
            2.2.2.RELEASE
        
        
            org.springframework.boot
            spring-boot-starter-aop
            2.2.2.RELEASE
        
        
            org.springframework.boot
            spring-boot-starter-web
            2.2.2.RELEASE
        
        
        
            org.springframework.boot
            spring-boot-starter-data-redis
            2.2.2.RELEASE
        
        
            org.apache.commons
            commons-pool2
            2.6.0
        

        
            org.apache.commons
            commons-lang3
            ${commons.lang3.version}
        

        
            log4j
            log4j
            1.2.17
        


        
            org.projectlombok
            lombok
            1.18.16
            compile
        



        
        
            org.springframework.boot
            spring-boot-starter-test
            2.2.2.RELEASE
            test
        
        
            junit
            junit
            4.12
            test
        
    

如果简单的引入的话,以下就足够了

    
            org.springframework.boot
            spring-boot-starter
            2.2.2.RELEASE
        
        
            org.springframework.boot
            spring-boot-starter-aop
            2.2.2.RELEASE
        
        
            org.springframework.boot
            spring-boot-starter-web
            2.2.2.RELEASE
        
      
        
            org.springframework.boot
            spring-boot-starter-test
            2.2.2.RELEASE
            test
        
        
            junit
            junit
            4.12
            test