-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Consider merging spring.autoconfigure.exclude from multiple profiles #27414
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
Thanks for the suggestion but this is working as designed and documented. Please see #12444 (comment) for links to a number of issues with further discussion on the matter. |
@wilkinsona I know it's designed, my request is treat |
That wasn’t clear to me from your original description which showed expected behaviour that is contrary to the documentation. That read like a bug report to me. A little bit of time explaining what you already now and what you are trying to do (rather than how you are trying to do it) would have been very helpful. We can’t make an exception for this one property. It would be confusing for it to behave differently and would break for anyone relying on the current behaviour. You haven’t really described what you are trying to do so offering advice is tricky. You could perhaps use the classpath to control which auto-configuration is active. Alternatively, as described in the issues linked to above, you can use some repetition in your configuration files. You would combine this with a profile expression such as If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. |
I faced with the same issue when attempted to modularize config: during local development I want selectively disable features via profiles, like Naive attempt was: ---
spring.config.activate.on-profile: no-redis-cache
spring.autoconfigure.exclude:
- org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
- org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration
---
spring.config.activate.on-profile: no-gcp-pubsub
spring.autoconfigure.exclude:
- org.springframework.cloud.gcp.autoconfigure.core.GcpContextAutoConfiguration
- org.springframework.cloud.gcp.autoconfigure.pubsub.GcpPubSubAutoConfiguration If two profiles are active only one To archive the goal of joint exclusions I used the feature introduced in #12586, see https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.1-Release-Notes#auto-configuration-exclusion public class SaPubSubConfiguration {
@Configuration
@Profile("no-gcp-pubsub")
@ImportAutoConfiguration(
exclude = {
org.springframework.cloud.gcp.autoconfigure.core.GcpContextAutoConfiguration.class,
org.springframework.cloud.gcp.autoconfigure.pubsub.GcpPubSubAutoConfiguration.class,
})
public static class DisabledConfig { }
@Configuration
@Profile("!no-gcp-pubsub")
public static class EnabledConfig {}
} public class RedisCacheManagerConfiguration {
@Configuration
@Profile("no-redis-cache")
@ImportAutoConfiguration(
exclude = {
org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration.class,
org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration.class,
})
public static class DisabledConfig { }
@Configuration
@Profile("!no-redis-cache")
@EnableCaching
public static class EnabledConfig { }
} |
When debugging of Set<String> allExclusions = this.autoConfigurationEntries.stream()
.map(AutoConfigurationEntry::getExclusions).flatMap(Collection::stream).collect(Collectors.toSet()); |
Uh oh!
There was an error while loading. Please reload this page.
if
noredis,nosecurity
activeexpected:
actual:
The text was updated successfully, but these errors were encountered: