From b35424478b4eeebac5dafa85c1c89dbcf367ecdb Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 15 Apr 2019 12:05:07 +0200 Subject: [PATCH] Deprecate Elasticsearch transport and Jest clients As of Spring Data Moore, the Elasticsearch high level REST client is supported for Spring Data repositories. The transport client is now deprecated and is likely to be removed in a future Spring Data release. This commit deprecates the transport client and marks all the associated configuration properties as deprecated. The Spring Boot starter depends on the `spring-data-elasticsearch` project, which now depends on both transport client and high level REST client. This commit also deprecates the Jest client, as Spring Boot will focus on supporting the high level REST client and the reactive client provided by Spring Data - both being in sync with the fast release pace of Elasticsearch. Closes gh-15008 --- .../ElasticsearchAutoConfiguration.java | 2 ++ .../jest/JestAutoConfiguration.java | 2 ++ ...itional-spring-configuration-metadata.json | 29 ++++++++++++++++++- .../main/asciidoc/spring-boot-features.adoc | 16 ++++++---- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.java index d1c24fa78c..ec72161790 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.java @@ -37,12 +37,14 @@ import org.springframework.data.elasticsearch.client.TransportClientFactoryBean; * @author Mohsin Husen * @author Andy Wilkinson * @since 1.1.0 + * @deprecated since 2.2.0 in favor of other auto-configured Elasticsearch clients */ @Configuration(proxyBeanMethods = false) @ConditionalOnClass({ Client.class, TransportClientFactoryBean.class }) @ConditionalOnProperty(prefix = "spring.data.elasticsearch", name = "cluster-nodes", matchIfMissing = false) @EnableConfigurationProperties(ElasticsearchProperties.class) +@Deprecated public class ElasticsearchAutoConfiguration { private final ElasticsearchProperties properties; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfiguration.java index a2ffc2c671..02f628781c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfiguration.java @@ -42,11 +42,13 @@ import org.springframework.util.Assert; * * @author Stephane Nicoll * @since 1.4.0 + * @deprecated since 2.2.0 in favor of other auto-configured Elasticsearch clients */ @Configuration(proxyBeanMethods = false) @ConditionalOnClass(JestClient.class) @EnableConfigurationProperties(JestProperties.class) @AutoConfigureAfter(GsonAutoConfiguration.class) +@Deprecated public class JestAutoConfiguration { @Bean(destroyMethod = "shutdownClient") diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 19f06f3c52..14b067436d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -305,6 +305,30 @@ "level": "error" } }, + { + "name": "spring.data.elasticsearch.cluster-name", + "type": "java.lang.String", + "description": "Elasticsearch cluster name.", + "deprecation": { + "reason": "The transport client support is deprecated. Use other supported clients instead." + } + }, + { + "name": "spring.data.elasticsearch.cluster-nodes", + "type": "java.lang.String", + "description": "Comma-separated list of cluster node addresses.", + "deprecation": { + "reason": "The transport client support is deprecated. Use other supported clients instead." + } + }, + { + "name": "spring.data.elasticsearch.properties", + "type": "java.util.Map", + "description": "Additional properties used to configure the client.", + "deprecation": { + "reason": "The transport client support is deprecated. Use other supported clients instead." + } + }, { "name": "spring.data.elasticsearch.repositories.enabled", "type": "java.lang.Boolean", @@ -389,7 +413,10 @@ "name": "spring.elasticsearch.jest.uris", "defaultValue": [ "http://localhost:9200" - ] + ], + "deprecation": { + "reason": "The Jest client support is deprecated. Use other supported clients instead." + } }, { "name": "spring.elasticsearch.rest.uris", diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 6bca9b3442..f8f20bf183 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -4782,17 +4782,18 @@ https://www.elastic.co/products/elasticsearch[Elasticsearch] is an open source, distributed, RESTful search and analytics engine. Spring Boot offers basic auto-configuration for Elasticsearch. -Spring Boot supports several HTTP clients: +Spring Boot supports several clients: * The official Java "Low Level" and "High Level" REST clients * https://github.com/searchbox-io/Jest[Jest] -The transport client is still being used by -https://github.com/spring-projects/spring-data-elasticsearch[Spring Data Elasticsearch], -which you can start using with the `spring-boot-starter-data-elasticsearch` "`Starter`". +The transport client is still available but its support has been deprecated in +https://github.com/spring-projects/spring-data-elasticsearch[Spring Data Elasticsearch] +and will be removed in a future release. Spring Boot provides a dedicated "`Starter`", +`spring-boot-starter-data-elasticsearch`. [[boot-features-connecting-to-elasticsearch-rest]] -==== Connecting to Elasticsearch by REST clients +==== Connecting to Elasticsearch using REST clients Elasticsearch ships https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/index.html[two different REST clients] that you can use to query a cluster: the "Low Level" client and the "High Level" client. @@ -4819,7 +4820,10 @@ any existing `RestClient` bean, reusing its HTTP configuration. [[boot-features-connecting-to-elasticsearch-jest]] -==== Connecting to Elasticsearch by Using Jest +==== Connecting to Elasticsearch using Jest +Now that Spring Boot supports the official `RestHighLevelClient`, Jest support is +deprecated. + If you have `Jest` on the classpath, you can inject an auto-configured `JestClient` that by default targets `http://localhost:9200`. You can further tune how the client is configured, as shown in the following example: