Spring Boot version
3.1.1
Bug description
The autoconfigured JacksonJsonpMapper bean used to depend on a global ObjectMapper bean before SpringBoot version v3.0.3.
After this commit introduced by SpringBoot version v3.0.3, the global ObjectMapper bean is not required when creating JacksonJsonpMapper bean.
However, the JacksonJsonpMapper bean creation condition @ConditionalOnBean(ObjectMapper.class) is not changed, resulting in JacksonJsonpMapper bean can be created only when ObjectMapper bean is present instead of the ObjectMapper class.
Bug resolving solution
Change @ConditionalOnBean(ObjectMapper.class) to @ConditionalOnClass(ObjectMapper.class)
Comment From: Pengfei-Lu
I don't figure it out how to mock the "ObjectMapper class is not loaded" senario, thus deleting the two failed withoutJsonbOrJacksonShouldDefineSimpleMapper & withJsonbShouldDefineJsonbMapper tests cases.
Is there any better solution?
Comment From: wilkinsona
You should be able to use contextRunner.withClassLoader(new FilteredClassLoader(ObjectMapper.class)).
Comment From: Pengfei-Lu
You should be able to use
contextRunner.withClassLoader(new FilteredClassLoader(ObjectMapper.class)).
It works! Please review the code.
Comment From: Pengfei-Lu
Thanks for the updates, @Pengfei-Lu. I think
ElasticsearchClientAutoConfigurationcould also be updated as it no longer needs to be ordered afterJacksonAutoConfiguration. Could you do that as well please?
Done. Please check.
Comment From: Pengfei-Lu
@wilkinsona If there is any update, please let me know, thanks!
Comment From: wilkinsona
Thanks very much for the PR, @Pengfei-Lu.