Updated Spring Boot and Spring Data Elasticsearch (asciidoc)

Peter-Josef Meisch 2019-07-14 13:54:34 +02:00
parent abe48ae284
commit 2caf14ce99

@ -1,10 +1,76 @@
Spring Boot defines in it's dependency bom the versions of the different libraries that are supported in the respective Spring Boot version. It specifies a version for Spring Data Elasticsearch and one for Elasticsearch as well.
== Versions
The following table lists the versions of Spring Data Elasticsearch and Elasticsearch that are specified in the dependency bom
The following table lists the versions of Spring Data Elasticsearch (SDE) and Elasticsearch (ES) that are specified in the dependency bom.footnote:[when creating this page, 2.1.6 is the current Spring Boot version, so the whole history is not added to this table]
* *SB*: Spring Boot version
* *SB-ES*: Elasticsearch version defined in the Spring Boot dependency bom
* *SDE*: Spring Data Elasticsearch version defined in the Spring Boot dependency bom
* *SDE-ES*: Elasticsearch version used by the given SDE version
The predefined version of Elasticsearch can be overwritten in your pom by setting the `<elasticsearch.version>` properties.
NOTE: defining a different version for Elasticsearch client libraries can lead to errors in the interaction of Spring Data Elasticsearch with the Elasticsearch client lib or in the communication with the Elasticsearch cluster.
|===
| Spring Boot | Spring Data Elasticsearch | Elasticsearch |
| 2.1.4.RELEASE | Lovelace-SR6 | 6.4.3 |
| SB | SB-ES | SDE | SDE-ES
| 2.1.6.RELEASE | 6.4.3 | Lovelace-SR9 / 3.1.9.RELEASE | 6.2.2
| 2.1.5.RELEASE | 6.4.3 | Lovelace-SR8 / 3.1.8.RELEASE | 6.2.2
| 2.1.4.RELEASE | 6.4.3 | Lovelace-SR6 / 3.1.6.RELEASE | 6.2.2
|===
== Workaround for some problems
=== Running Spring Data Elasticsearch 3.2.0.RC1 with Spring Boot 2.1.6.RELEASE and Actuator.
To set up the connection to the Elasticsearch cluster with the Java configuration a configuration bean is used:
[source,java]
----
@Configuration
public class RestClientConfig extends AbstractElasticsearchConfiguration {
@Override
@Bean
public RestHighLevelClient elasticsearchClient() {
final ClientConfiguration clientConfiguration = ClientConfiguration.builder()
.connectedTo("someHost:443") //
.usingSsl() //
.withBasicAuth("elastic", "somePassword") //
.build();
return RestClients.create(clientConfiguration).rest();
}
}
----
When Spring Boot starts up the actuator and this finds the Elasticsearch clients in the classpath, it checks for the existence of a `RestClient` bean (this is the low level rest client from Elasticsearch). This is not found, so a new `RestClient` is created, that tries to connect to _localhost_. To provide the actuator with correct bean, it is necessary to add the bean to the configuration:
[source,java]
----
@Configuration
public class RestClientConfig extends AbstractElasticsearchConfiguration {
// needed for actuator
@Bean
public RestClient restClient(RestHighLevelClient client) {
return client.getLowLevelClient();
}
@Override
@Bean
public RestHighLevelClient elasticsearchClient() {
final ClientConfiguration clientConfiguration = ClientConfiguration.builder()
.connectedTo("someHost:443") //
.usingSsl() //
.withBasicAuth("elastic", "somePassword") //
.build();
return RestClients.create(clientConfiguration).rest();
}
}
----