使用 springboot 3.0.0 测试
当新的ElasticsearchClient在类路径中时,它会触发,ElasticsearchClientAutoConfiguration然后覆盖应用程序对象映射器/通过配置的映射器Jackson2ObjectMapperBuilder。
此问题的重现者;https://github.com/manofthepeace/spring3-elasticClient-mapperissue
重现步骤;
- 通过测试运行测试
mvn test将通过 - 修改 pom.xml 并取消注释 elasticsearch-java 依赖项
mvn test通过测试运行测试将失败- 正在
TestingWebApplication.java使用@SpringBootApplication(exclude = ElasticsearchClientAutoConfiguration.class) mvn test通过测试运行测试将通过
预期行为;应该RestClientTransport使用新的 ObjectMapper,或者用户提供的 ObjectMapper,而不是 spring-mvc / 全局使用的 ObjectMapper。可以使用new JacksonJsonpMapper()或通过将 objectMapper 传递给JacksonJsonpMapper构造函数来完成。
