Open p-daniil opened 1 year ago
I have similar but different problem where my configuration class annotated with @RefreshScope
and method annotated with @Bean
registers BeanDefinition with null
BeanClass. ConditionalOnMissingBean checks match using beanclass so it creates another bean with type even if refreshscope bean already exist
Hi!
I'm trying to integrate RefreshScope in my project. The problem is that
@ConditionalOnBean
condition doesn't match bean, annotated with@RefreshScope
. It works fine with Spring Boot 2.1.4.RELEASE, but doesn't work with version 2.6.6.I have debugged and found, that the root cause is in this line: https://github.com/spring-projects/spring-boot/blob/d4a91004b5b04f0151e9b5df65dceb6443a35e42/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java#L186
Is it expected behaviour or it's a bug? My expectations is that refresh scope bean proxy should trigger real bean creation, because it's injected in provider and it shouldn't be blocked by
@ConditionalOnBean
condition.Example I have three autoconfigurations, executing one after another.
TokenProviderAutoConfiguration
depends on bean, which can be created or not inTokenClientAutoConfiguration
. On this bean I added@RefreshScope
. After thatTokenProviderAutoConfiguration
didn't added to context, because of@ConditionalOnBean
condition (but only in later Spring Boot version)