diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchClientConfigurations.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchClientConfigurations.java index 008ea9dd27bc..63ec135c01b1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchClientConfigurations.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchClientConfigurations.java @@ -31,6 +31,7 @@ import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -44,7 +45,7 @@ class ElasticsearchClientConfigurations { @ConditionalOnMissingBean(JsonpMapper.class) - @ConditionalOnBean(ObjectMapper.class) + @ConditionalOnClass(ObjectMapper.class) @Configuration(proxyBeanMethods = false) static class JacksonJsonpMapperConfiguration { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchClientAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchClientAutoConfigurationTests.java index c290db791f9f..2508353a7230 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchClientAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchClientAutoConfigurationTests.java @@ -18,9 +18,7 @@ import co.elastic.clients.elasticsearch.ElasticsearchClient; import co.elastic.clients.json.JsonpMapper; -import co.elastic.clients.json.SimpleJsonpMapper; import co.elastic.clients.json.jackson.JacksonJsonpMapper; -import co.elastic.clients.json.jsonb.JsonbJsonpMapper; import co.elastic.clients.transport.ElasticsearchTransport; import co.elastic.clients.transport.rest_client.RestClientTransport; import com.fasterxml.jackson.databind.ObjectMapper; @@ -62,21 +60,6 @@ void withRestClientAutoConfigurationShouldDefineClientAndSupportingBeans() { .hasSingleBean(ElasticsearchClient.class)); } - @Test - void withoutJsonbOrJacksonShouldDefineSimpleMapper() { - this.contextRunner.withUserConfiguration(RestClientConfiguration.class) - .run((context) -> assertThat(context).hasSingleBean(JsonpMapper.class) - .hasSingleBean(SimpleJsonpMapper.class)); - } - - @Test - void withJsonbShouldDefineJsonbMapper() { - this.contextRunner.withConfiguration(AutoConfigurations.of(JsonbAutoConfiguration.class)) - .withUserConfiguration(RestClientConfiguration.class) - .run((context) -> assertThat(context).hasSingleBean(JsonpMapper.class) - .hasSingleBean(JsonbJsonpMapper.class)); - } - @Test void withJacksonShouldDefineJacksonMapper() { this.contextRunner.withConfiguration(AutoConfigurations.of(JacksonAutoConfiguration.class))