Spring Data java.lang.NoSuchMethodError

时间:2014-06-24 07:33:38

标签: java spring elasticsearch spring-data spring-data-elasticsearch

春天正在投掷

java.lang.NoSuchMethodError: org.springframework.data.util.ClassTypeInformation.from(Ljava/lang/Class;)Lorg/springframework/data/util/ClassTypeInformation;
        at org.springframework.data.elasticsearch.core.MappingBuilder.isEntity(MappingBuilder.java:260)
        at org.springframework.data.elasticsearch.core.MappingBuilder.mapEntity(MappingBuilder.java:97)
        at org.springframework.data.elasticsearch.core.MappingBuilder.buildMapping(MappingBuilder.java:70)
        at org.springframework.data.elasticsearch.core.ElasticsearchTemplate.putMapping(ElasticsearchTemplate.java:156)
        at org.springframework.data.elasticsearch.repository.support.AbstractElasticsearchRepository.putMapping(AbstractElasticsearchRepository.java:84)
        at org.springframework.data.elasticsearch.repository.support.AbstractElasticsearchRepository.<init>(AbstractElasticsearchRepository.java:73)
        at org.springframework.data.elasticsearch.repository.support.NumberKeyedRepository.<init>(NumberKeyedRepository.java:36)
        at org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryFactory.getTargetRepository(ElasticsearchRepositoryFactory.java:73)
        at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:147)
        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:142)
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1442)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:876)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:818)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:735)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)

这是我的存储库,这是导致问题的存储库

@Repository("clinicalDocumentRepository")
public interface ConsultationDocumentRepo extends ElasticsearchCrudRepository<ConsultationDocument,Long> {

如何解决此问题?

2 个答案:

答案 0 :(得分:4)

ClassTypeInformation在1.1.0版中引入了方法:

public static <S> TypeInformation<S> from(Class<S> type) {

确保spring-data-commons版本为&gt; = 1.1.0

答案 1 :(得分:1)

对于当前的Spring Data Elasticsearch版本(1.0.0.RELEASE),您需要1.8.0.RELEASE中的Spring Data Commons(正如pom建议的那样)。

一般来说,我们建议使用版本系列BOM(如文档here所示),以确保获得匹配版本中的所有Spring Data库。 BOM的当前版本为Dijkstra-RELEASE