-
Notifications
You must be signed in to change notification settings - Fork 40.9k
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 changed behavior from boot 1.5 to 2.0 #13938
Comments
In Spring Boot 1.5 the The reason we do this is so that a custom Your original code was working more by accident than design I'm afraid. The
|
I'd probably recommend moving |
@philwebb Hmm, understood. So how would I have some configuration only applied to web integration tests? I worked-around it using |
@jwedel You could use the |
Thanks for the detailed explanation and rationale, @philwebb! |
Hi,
we've just migrated an application from boot 1.5 to 2.0 following the migration guide. Our web integration tests stopped working after migration and fail with a
NoSuchBeanDefinitionException
.I know that there is a section about a semantics change regarding
@ConditionalOnBean
in the migration guide, but we only have one annotation in the test class so AND/OR won’t apply.I've created a stripped-down example to reproduce the issue:
https://github.com/jwedel/conditional-on-bean-test
Run
ConditionalTest
as it is and it works (test green). Change the parent spring boot starter version in the pom to2.0.3.RELEASE
and it fails with the above exception.At the core, this
@Configuration
class does not get loaded when running a web integration test:Why am I doing this? We need a bean autowired only in web integration thats that needs the TestRestTemplate.
I also read an answer by @wilkinsona on StackOverflow that quotes the docs saying it will not work because
@Configuration
will be evaluated before auto configuration. But then I wonder why it worked on the first place.I might be wrong, but IMO it's either a bug or a breaking change that was not documented in the migration guide...
The text was updated successfully, but these errors were encountered: