I am learning spring-boot-starter-data-elasticsearch with gradle. I have defined below dependencies in my .gradle file:
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'
}
I am using Elastic search version of 2.3.1. I created one class by extending ElasticsearchRepository. Now when i try to query Elasticsearch i am getting below exception
java.lang.NoSuchMethodError: com.fasterxml.jackson.dataformat.smile.SmileGenerator.getOutputContext()Lcom/fasterxml/jackson/core/json/JsonWriteContext;`
Please help me to resolve this.
This is a typical example where you're taking control of version dependencies yourself and you chose incompatible versions. Why are you doing this?
One of the strength of Spring Boot is that it provides a coherent and consistent dependency management. Rather than specifying the version yourself, you let a particular version of Spring Boot manages that for you. This works both with Maven and Gradle.
You can see what a typical gradle build file looks like by heading to https://start.spring.io, select Gradle project and type your dependencies in the search box (web, actuator, elasticsearch). Jackson is already provided by web and SLF4j comes with every starter.