Spring: How to do AND in Profiles?

前端 未结 7 1576
太阳男子
太阳男子 2020-12-25 10:40

Spring Profile annotation allows you to select profiles. However if you read documentation it only allows you to select more than one profile with OR operation. If you speci

7条回答
  •  悲&欢浪女
    2020-12-25 11:00

    Another kind of trick but might work in many scenarios is put @Profile annotation on @Configuration and the other @Profile on @Bean - that creates logical AND between 2 profiles in java-based spring config.

    @Configuration
    @Profile("Profile1")
    public class TomcatLogbackAccessConfiguration {
    
       @Bean
       @Profile("Profile2")
       public EmbeddedServletContainerCustomizer containerCustomizer() {
    

提交回复
热议问题