Failed to load ApplicationContext异常java.lang.NoSuchMethodError

来源:互联网 发布:淘宝买到三无产品 编辑:程序博客网 时间:2024/06/04 18:48

突然springmvc项目不能注入失败了。

java.lang.IllegalStateException: Failed to load ApplicationContext    at (...此处忽略一些)Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDaoImpl': Injection of autowired dependencies failed; nested exception is java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotatedElementUtils.forAnnotations([Ljava/lang/annotation/Annotation;)Ljava/lang/reflect/AnnotatedElement;    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)    at (...此处忽略一些)Caused by: java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotatedElementUtils.forAnnotations([Ljava/lang/annotation/Annotation;)Ljava/lang/reflect/AnnotatedElement;    at org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver.findValue(QualifierAnnotationAutowireCandidateResolver.java:346)    at org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver.getSuggestedValue(QualifierAnnotationAutowireCandidateResolver.java:331)    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1083)    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:659)    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)    ... 41 more

bug原因:
JUnit的包和Spring-test的版本冲突。

错误的依赖

<dependency>            <groupId>junit</groupId>            <artifactId>junit</artifactId>            <version>4.12</version>            <scope>test</scope>        </dependency>        <dependency>            <groupId>org.springframework</groupId>            <artifactId>spring-test</artifactId>            <version>4.2.6.RELEASE</version>            <scope>test</scope>        </dependency>

将spring-test的版本号换成4.1.6,就没有问题了

<dependency>            <groupId>junit</groupId>            <artifactId>junit</artifactId>            <version>4.12</version>            <scope>test</scope>        </dependency>        <dependency>            <groupId>org.springframework</groupId>            <artifactId>spring-test</artifactId>            <version>4.1.6.RELEASE</version>            <scope>test</scope>        </dependency>
阅读全文
0 0
原创粉丝点击