Reputation: 203
i want ElasticSearch with autoconfiguration, set application.yml like below:
spring:
elasticsearch:
rest:
uris:
- http://localhost:9200
spring boot version : 2.4.3
and using io.spring.dependency-management
.
maybe ElasticsearchRestClientAutoConfiguration
use in autoconfig, but reference document so much little.
i want elasticsearch auto-config with a yml data.
how can use it?
Upvotes: 1
Views: 3109
Reputation: 3390
Your application.yml
is enough. You don't need to create a configuration class, if your goal is simply use the default configurations for the ElasticsearchRestClient
. Spring boot will identify that spring-data-elasticsearch
is on the classpath and trigger the auto-configuration using the properties on your application.yml
.
In fact, you should not extend ElasticsearchRestClientAutoConfiguration
. This is just a auto-configuration class triggered by Spring Boot in order to configure your Elasticsearch Client.
If you need to programmatically supply any configuration for your client through Java, instead of your configuration file, then you can manually configure a client by extending AbstractElasticsearchConfiguration
to configure yourself a RestHighLevelClient
Resources that may help you:
Spring Data Elasticsearch Reference Documentation
AbstractElasticsearchConfiguration javadoc
Upvotes: 2