So I am trying to get my Spring Boot webservice to talk to Elasticsearch (I have another Java app that works)
The error I am getting is
DependencyException: Error creating bean with name 'searchController': Unsatisfied dependency expressed through field 'searchService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'searchService': Unsatisfied dependency expressed through field 'searchRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'searchRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder.execute()Lorg/elasticsearch/action/ListenableActionFuture; 2018-10-27 22:18:49.139 INFO 1925 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
My dependencies (Gradle) are
compile group: 'org.elasticsearch.plugin', name: 'transport-netty4-client', version: '6.4.2'
compile group: 'org.elasticsearch.client', name: 'transport', version: '6.4.2'
compile 'org.elasticsearch:elasticsearch:6.4.2'
compile('org.springframework.boot:spring-boot-starter-data-elasticsearch')
My model
@org.springframework.data.elasticsearch.annotations.Document(indexName = "burf", type = "pages")
data class Result(@Id val handle: String,
val url: String,
val title: String,
val body: String,
val meta_description: String?) {
}
Config
@Configuration
@EnableElasticsearchRepositories(basePackages = arrayOf("com.burfdevelopment.skynet.repository\n"))
@ComponentScan(basePackages = arrayOf("com.burfdevelopment.skynet.service"))
class Config {
@Value("\${elasticsearch.home:/usr/local/Cellar/elasticsearch}")
private val elasticsearchHome: String? = null
@Value("\${elasticsearch.cluster.name:skynet}")
private val clusterName: String? = null
@Bean
fun client(): Client {
val settings = Settings.builder()
.put("cluster.name", clusterName).build()
return PreBuiltTransportClient(settings).addTransportAddress(TransportAddress(InetAddress.getByName("192.168.0.100"), 9300))
}
@Bean
fun elasticsearchTemplate(): ElasticsearchOperations {
return ElasticsearchTemplate(client())
}
}
Repository
interface SearchRepository : ElasticsearchRepository<Result, String> {
fun findByTitle(name: String, pageable: Pageable): Page<Result>
}
Anyone got any idea whats wrong?