mongo的spring数据引起:java.lang.AbstractMethodError

时间:2014-07-05 02:29:25

标签: spring mongodb

我将弹簧数据用于jpa和mongo。

依赖

春季版是4.0.2.RELEASE

spring-data-jpa版本是1.4.3.RELEASE

spring-data-mongodb版本是1.2.0.RELEASE

xml config

<context:component-scan base-package="develop" />

<jpa:repositories base-package="develop.erp"
        entity-manager-factory-ref="entityManagerFactory"
        transaction-manager-ref="transactionManager" /> 


<mongo:repositories base-package="develop.doc" />

模型

@Document
public class OrderItem extends AbstractDocument {


    enter code here
    @Id
    private BigInteger id;

    private Integer orderNumber;

    public get and set method ...
}

public interface IOrderItemDao extends PagingAndSortingRepository<OrderItem, BigInteger> {


    List<OrderItem> findByOrderNumber(Integer number);
}

例外

Caused by: java.lang.AbstractMethodError
    at org.springframework.data.repository.query.Parameters.getBindableParameters(Parameters.java:235)
    at org.springframework.data.repository.query.Parameters.assertEitherAllParamAnnotatedOrNone(Parameters.java:262)
    at org.springframework.data.repository.query.Parameters.<init>(Parameters.java:85)
    at org.springframework.data.mongodb.repository.query.MongoParameters.<init>(MongoParameters.java:47)
    at org.springframework.data.mongodb.repository.query.MongoQueryMethod.createParameters(MongoQueryMethod.java:76)
    at org.springframework.data.repository.query.QueryMethod.<init>(QueryMethod.java:70)
    at org.springframework.data.mongodb.repository.query.MongoQueryMethod.<init>(MongoQueryMethod.java:62)
    at org.springframework.data.mongodb.repository.support.MongoRepositoryFactory$MongoQueryLookupStrategy.resolveQuery(MongoRepositoryFactory.java:119)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:304)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:161)
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:162)
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:44)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:144)

有人可以有任何想法吗?

非常感谢..

2 个答案:

答案 0 :(得分:0)

在我的案例中,我的项目中有spring-data-solr(2.0.1)和spring-data-jpa(1.9.1)。我注意到SolrQueryLookupStrategy正在从spring-data-commons实现QueryLookupStrategy接口,该接口是从spring-data-jpa jar传递的。问题是新的solr与旧的spring-data-jpa不兼容 - QueryLookupStrategy中的方法签名已更改且代码未正确编译。将spring-data-jpa压缩到1.10.1解决了这个问题。我假设你有类似的问题。追踪引发异常的位置并在spring jar中搜索编译问题。

答案 1 :(得分:0)

这是由于spring-data和db-driver依赖项的版本不兼容。请检查db-driver的版本是否与提供的spring-data依赖项兼容。我遇到了同样的问题,通过增加“ spring-data”的版本来解决。