更改Spring MVC应用程序的jar集导致java.lang.NoSuchMethodError错误

时间:2014-02-06 18:07:47

标签: java spring hibernate

我正在使用Spring WEB MVC应用程序。我需要添加Hibernate持久层,所以我从Github下载了Spring Pet Clinic应用程序: http://spring.io/blog/2013/03/21/spring-petclinic-is-on-github

仅从Petclinic应用程序(Spring版本4.0.1)将jar更改为jar集导致以下错误

12:38:54.039 [localhost-startStop-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory -   Creating shared instance of singleton bean 'viewResolver'
12:38:54.039 [localhost-startStop-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'viewResolver'
12:38:54.061 [localhost-startStop-1] ERROR o.s.web.context.ContextLoader - Context initialization failed
java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.InjectionMetadata.needsRefresh(Lorg/springframework/beans/factory/annotation/InjectionMetadata;Ljava/lang/Class;)Z
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:383) ~[spring-orm-4.0.1.RELEASE.jar:4.0.1.RELEASE]
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:332) ~[spring-orm-4.0.1.RELEASE.jar:4.0.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:844) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]

1 个答案:

答案 0 :(得分:6)

Spring模块的版本似乎存在冲突。

  

at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:332)〜[spring-orm-4.0.1.RELEASE.jar:4.0.1.RELEASE]

     

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:844)< strong>〜[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]

确保所有Spring依赖项都具有相同的版本。