【发布时间】:2019-08-16 01:05:52
【问题描述】:
所以,我正在尝试集成 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 属性对我没有帮助
【问题讨论】:
-
尝试将 log4j jar 文件添加到您的类路径
标签: spring-boot elasticsearch classpath