-
Notifications
You must be signed in to change notification settings - Fork 41.1k
How can I exclude the configuration enabled through a Boot protected inner configuration class? #5427
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
Comments
You can't. Exclude only works on auto-configuration classes (top level classes) referenced in the documentation. As for the concrete problem, I am sure @dsyer knows more than I am. |
I guess I don't see a problem with making |
This is what I actually did in the end. But that is "all or nothing" in terms of what Spring Boot can do for you in the future. Maybe there is a need for finer control on what Spring boot auto-config capabilities can be turned on and off. And then, this breaks the standardization of the configuration. Again, this could be problematic in the future. The side story is that I needed this to address this issue (714). I'm not the expert in this case, so I'm just posting my concerns. |
+1 for a way of disabling autoconfiguration in inner classes. I wanted to do the same (disable inner class in Jackson Joda Time autoconfiguration) and ended up workarounding it by not customizing the configuration. |
We can't easily disable inner-configurations. I'd rather take each need on a case-by-case basis and work out why a specific inner-configuration couldn't be used. @dfernandezm Feel free to raise a new issue if you think there is some additional |
We're not keen to increase the complexity of excludes. The inner configs are really meant as an implementation detail. |
Is there a way to specify package name for exclude? Would be easy if there is an option to specify "org.apache.camel" in below case.
The camel packages are using RelaxedPropertyResolver which is no more present in springboot 2.0
|
@espre05 This issue is closed and we prefer not to use the tracker for questions. Please ask things like this on stackoverflow.com or join us on gitter. |
This is still an issue with Spring Boot Autoconfiguration. There should be a way to disable a built-in autoconfiguration and provide more logic in there. Real use case: we use a secret store and need to use its APIs to get the RSA public key (JWT token verifier key). We need to change the implementation (that can only read the token value from an URL) and we have no way to change the default implementation. This should be considered an enhancement request, not a question. |
Nobody disagree with that and @philwebb already answered that concern in a comment above:
Please share your use case in a separate issue. A small sample that illustrates what you are doing right now is preferable to help us locate the problem.
This wasn't a question, this was a request that got declined, see this comment above and the |
@snicoll and @dsyer: I was having the similar problem with configuration exclusion. A simple unit test for My unit test works, but it loads the EnableAutoConfiguration Error
Spring Context
SuggestionThere should be a new annotation
The sole responsibility of exclusion would be the developer and he/she knows the intentions behind |
I am sorry to say that I don't think this is reasonable. An inner configuration of an auto-configuration is a internal detail of what the auto-configuration provides. If you think you have to exclude it, it might be because a condition or some sort of customization is missing and/or the test should be structured differently. We'd prefer to deal with those on a case-by-base basis as @philwebb said above already. |
I have a concrete situation where I want to exclude the configuration implemented by
org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration
I tried both
exclude = {ResourceServerTokenServicesConfiguration.class}
andexcludeName = {"org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration"}
but none is working.The scenario is that I want to implement my own
ResourceServerTokenServices
but when the upstream beans have to autowire this bean, I get this error:Clearly, the boot JwtTokenServicesConfiguration configuration is not omitted. There would be a hack here where I can make the
JwtTokenCondition
fail, but this is a low hack.Here is the simple configuration that I'm using:
this is the configuration file:
and the dependencies:
The text was updated successfully, but these errors were encountered: