Spring Data Elasticsearch“创建elasticsearchTemplate时出错”

时间:2017-12-01 17:02:11

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

我正在使用:
  - elasticsearch 5.4。
  - 春季靴子1.4.7.RELEASE
  - spring-data-elasticsearch 3.0.1.RELEASE。

@Configuration
@EnableElasticsearchRepositories(basePackages = "com.landfiles.farms.repository")
public class ESConfig {

  @Value("${elasticsearch.host}")
  private String EsHost;

  @Value("${elasticsearch.port}")
  private Integer EsPort;

 @Bean
  public Client client() throws Exception {
    return new PreBuiltTransportClient(Settings.EMPTY)
            .addTransportAddress(new InetSocketTransportAddress(
                    InetAddress.getByName(EsHost), EsPort));
  }

  @Bean
  public ElasticsearchOperations elasticsearchTemplate() throws Exception {
    return new ElasticsearchTemplate(client());
  }
}

我在应用程序运行时失败了:

java.lang.NoClassDefFoundError: org/springframework/data/mapping/model/Property 

完全stackstrace:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'elasticsearchTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'elasticsearchTemplate' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'elasticsearchConverter' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'elasticsearchConverter' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mappingContext' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/mapping/model/Property

Jira的问题已联系(未回答):https://jira.spring.io/browse/DATAES-364

有人有一个有效的世界示例吗?

谢谢!

0 个答案:

没有答案