I basically have a bean in Spring that I wanted to activate only when 2 profiles are active. Basically, it would be like:
@Profile({\"Tomcat\", \"Linux\"})
p
Unfortunately, @Profile
activates if any listed profile is active. There are a couple of ways around this.
@Profile("Tomcat")
annotation to a top-level configuration class, and then apply @Profile("Windows")
to a nested configuration class (or @Bean
method).It looks like what you're trying to do would be clean to write if you were using Spring Boot autoconfiguration classes; if it's practical to introduce autoconfiguration at this stage of your application's lifecycle, I recommend considering it.