This is first time I try to create a library for SpringBoot application with autoconfiguration.
I have my configuration entrypoint configured like (some parts are redacted)
@AutoConfigurationPackage
@AutoConfigureAfter({RestTemplateAutoConfiguration.class, JacksonAutoConfiguration.class})
@AutoConfigureBefore({org.zalando.logbook.autoconfigure.LogbookAutoConfiguration.class})
@ConditionalOnWebApplication
@EnableConfigurationProperties({...})
@Configuration(...)
@ConditionalOnBean(ObjectMapper.class)
public class MyAutoConfiguration {
It works in one of projects, but fails in another. In the letter case I can see in the debug log that ObjectMapper bean is created before MyAutoConfiguration, yet it fails to pass the condition check
ObjectMapper is created:
///line ~800
JacksonAutoConfiguration.JacksonObjectMapperConfiguration#jacksonObjectMapper matched:
- @ConditionalOnMissingBean (types: com.fasterxml.jackson.databind.ObjectMapper; SearchStrategy: all) did not find any beans (OnBeanCondition)
////line ~2080
........redacted.MyAutoConfiguration:
Did not match:
- @ConditionalOnBean (types: com.fasterxml.jackson.databind.ObjectMapper; SearchStrategy: all) did not find any beans of type com.fasterxml.jackson.databind.ObjectMapper (OnBeanCondition)
Matched:
- @ConditionalOnWebApplication (required) found 'session' scope (OnWebApplicationCondition)
so as a newbie I would say that conditions are met as ObjectMapper is created way before MyAutoConfiguration, yet check fails. Why is that??
PS. I thought that it might be due to version missmach (different version used for building the library and different used in the runtime) but after checking version is the same in the lib and runtime