Spring Boot v1.2由于RepositoryInformation引起的AbstractMethodError

时间:2015-01-18 17:39:11

标签: spring-boot spring-data-jpa spring-test

我正在构建一个基于Spring Boot v1.2的应用程序。虽然我的应用程序成功启动并且执行良好(到目前为止......),但由于AbstractMethodError,我无法使用spring boot框架进行测试。

跟踪的最后几行如下

Caused by: java.lang.AbstractMethodError: org.springframework.data.jpa.repository.support.LockModeRepositoryPostProcessor.postProcess(Lorg/springframework/aop/framework/ProxyFactory;Lorg/springframework/data/repository/core/RepositoryInformation;)V
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:185)
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:239)
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:225)
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:84)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1627)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1564)
    ... 55 more

为了分析上面的错误,我检查了包含上述类的classpath中的jar文件。所以信息可以在下面找到

jar:file:/C:/rearch/intellij-workspace/springbootproj/lib/spring-aop-4.1.2.RELEASE.jar!/org/springframework/aop/framework/ProxyFactory.class
jar:file:/C:/rearch/mavenrepo/org/springframework/data/spring-data-commons/1.9.1.RELEASE/spring-data-commons-1.9.1.RELEASE.jar!/org/springframework/data/repository/core/RepositoryInformation.class
jar:file:/C:/rearch/intellij-workspace/springbootproj/lib/spring-data-jpa-1.3.3.jar!/org/springframework/data/jpa/repository/support/LockModeRepositoryPostProcessor.class
jar:file:/C:/rearch/intellij-workspace/springbootproj/lib/spring-test-4.1.2.RELEASE.jar!/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.class

我不确定为什么spring-data-commons来自maven repostory文件夹,而其他人则来自项目库。

在我调试时,我同时需要你的帮助来确定上述库之间的版本兼容性。 我无法准确指出导致错误的确切原因。请帮忙!

由于

3 个答案:

答案 0 :(得分:6)

问题在于,与Spring引导应用程序冲突的库的intellij配置。我手动从Maven存储库中替换了所需的库,这对我来说很有用。


根据Elron的要求..

在资源管理器中打开项目文件夹,验证项目中的第三方库版本是否与您实际期望的版本相匹配。如果某些内容不匹配,只需将文件替换为您期望的文件即可。在我的情况下,因为我使用Maven,我没有看到需要在项目下的新lib文件夹中明确地保存这些库。所以,我刚刚删除了lib文件夹中的所有文件,事情又开始了。

答案 1 :(得分:2)

要修复此错误,请将spring-data-jpa版本更改为1.5.0.RELEASE

答案 2 :(得分:0)

我遇到过这个问题。

摆脱spring-data-commons并将spring-data-jpa版本更改为1.9.0.RELEASE。

有关详细信息,请点击此链接: - Spring Data Rest PagingAndSortingRepository AbstractMethodError (RepositoryFactorySupport)