通过Spring-Boot-Starter-Data-Elasticsearch查询Elasticsearch时的例外



我正在学习带有gradle的spring-boot-starter-data-elasticsearch。我在.gradle文件中定义了以下依赖项:

dependencies {
compile 'org.slf4j:slf4j-api:1.7.21'
compile 'org.springframework.boot:spring-boot-starter-data-elasticsearch:1.4.2.RELEASE'
compile 'org.springframework:spring-test:4.1.2.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-logging:1.4.2.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-web:1.4.2.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-actuator:1.4.2.RELEASE'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.6'
compile 'com.fasterxml.jackson.core:jackson-core:2.7.6'
testCompile 'junit:junit:4.12'
}

我正在使用2.3.1的弹性搜索版本。我通过扩展ElasticsearchRepository创建了一个类。现在,当我尝试查询Elasticsearch时,我正在以下异常

java.lang.nosuchmethoderror:com.fasterxml.jackson.dataformat.smile.smilegenerator.getOutputcontext()

请帮助我解决这个问题。

这是一个典型的示例,您要自己控制版本依赖项,并且选择了不兼容的版本。你为什么要这样做?

春季启动的强度之一是它提供了连贯且一致的依赖性管理。您没有自己指定版本,而是让特定版本的Spring Boot为您管理。这既适用于Maven和Gradle。

您可以通过前往https://start.spring.io,选择Gradle项目并在搜索框中键入依赖项(Web,Actuator,lasticsearch),从而看到典型的Gradle构建文件的样子。杰克逊已经由Web提供,SLF4J随附了每个入门者。

最新更新