因此,我正在尝试集成Elasticsearch,但是我的Spring Boot应用程序无法正常启动
我的pom.xml文件
<properties>
<elasticsearch.version>6.8.0</elasticsearch.version>
</properties>
<dependencies>
....
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-spring</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>6.5.4</version>
</dependency>
....
</dependencies>
和配置Bean:
@Configuration
@EnableElasticsearchRepositories(basePackages = "com.contacts.demo.elasticsearch")
public class ElasticSearchConfiguration {
@Bean
public Client client() throws UnknownHostException {
Settings settings = Settings.builder().put("cluster.name", "elasticsearch").put("client.transport.sniff", true).build();
TransportClient transportClient = new PreBuiltTransportClient(settings);
transportClient.addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), 9300));
return transportClient;
}
}
有了这个我就得到
以下方法不存在:
org.elasticsearch.common.logging.Loggers.getLogger(Ljava/lang/Class;)Lorg/apache/logging/log4j/Logger;
该方法的类org.elasticsearch.common.logging.Loggers可从以下位置获得:
jar:file:/home/user/.m2/repository/org/elasticsearch/elasticsearch/6.8.0/elasticsearch-6.8.0.jar!/org/elasticsearch/common/logging/Loggers.class
它是从以下位置加载的:
file:/home/user/.m2/repository/org/elasticsearch/elasticsearch/6.8.0/elasticsearch-6.8.0.jar
操作:
更正应用程序的类路径,使其包含org.elasticsearch.common.logging.Loggers的单个兼容版本
我看过一些相同的主题,但是设置elasticsearch.version属性对我没有帮助
答案 0 :(得分:0)
在您似乎正在使用所有Elasticsearch其他所有模块的org.elasticsearch.client:transport
时,您已将6.5.4
的版本改写为6.8.0
。 org.elasticsearch.client:transport
包含在Spring Boot的Elasticsearch依赖管理中,因此我建议从您的pom中删除<version>
并改用托管版本:
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
</dependency>