2015-10-10 30 views
0

彈簧的數據升級從1.8到1.9,我發現了以下錯誤後:升級到春天數據1.9

Caused by: java.lang.IllegalStateException: No suitable constructor found on interface com.acme.util.RepositoryEx to match the given arguments: [Ljava.lang.Object;@4ef820c3 
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getTargetRepositoryViaReflection(RepositoryFactorySupport.java:338) 
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:91) 
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:71) 
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:185) 
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:251) 
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:237) 
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) 
    ... 87 more 

我有一個簡單RepositoryEx類,如:

public interface RepositoryEx<T, ID extends Serializable> extends JpaRepository<T, ID>, 
     JpaSpecificationExecutor<T> { 

    List<T> findAll(Specification<T> spec, Sort sort, long offset, long count); 


} 

那我其他存儲庫接口全部繼承,有什麼我需要添加?

謝謝,傑森

回答

1

我剛碰到這個問題。我的基礎知識庫實現類擴展了SimpleJpaRepository,並且只有一個構造函數,其參數Class<T> domainClass, EntityManager em。添加下面的構造函數解決了我的問題:

public MyBaseRepositoryImpl(JpaEntityInformation<T, ?> entityInformation, EntityManager entityManager) { 
    super(entityInformation, entityManager); 
} 
+0

是的,這個工程!我從https://jira.spring.io/browse/DATACMNS-763得到了這個答案 – zhuguowei