java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.isInJavaLangAnnotationPackage(Ljava/lang/annotation/Annotation;)Z

前端 未结 5 1575
滥情空心
滥情空心 2020-12-01 16:08

Am very new to spring and JUnit. Am trying to run a simple JUnit test case for spring service class, but it fails and I get this exception.I didnt write any test yet, but t

5条回答
  •  清歌不尽
    2020-12-01 16:40

    The problem is that you are mixing different versions of Spring, you are mixing (2.0.8, 3.1.4 and 4.0.2) in your project. That is trouble waiting to happen.

    To prevent these kind of things there is now a so called "bill of materials" POM which you can import.

    You need to add a dependencyManagement section to import the bom.

    
        
            
                org.springframework
                spring-framework-bom
                4.0.5.RELEASE
                pom
                import
            
        
    
    

    Now in your dependencies you can remove the version and replace spring-dao with spring-orm. Added benefit is that all your spring-* dependencies will now be managed to the latest release and you only have a single location for your version number.

    
        org.springframework
        spring-beans
    
    
        org.springframework
        spring-context
    
    
        org.springframework
        spring-context-support
    
    
        org.springframework
        spring-core
    
    
        org.springframework
        spring-jdbc
    
    
        org.springframework
        spring-orm
    
    

    You could apply the same trick for Spring Data as that also has a bom.

提交回复
热议问题