-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ConditionalOnBean doesn't match RefreshScope Bean #1191
Labels
Comments
I have similar but different problem where my configuration class annotated with |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)The text was updated successfully, but these errors were encountered: