Spring: How to do AND in Profiles?

前端 未结 7 1480
太阳男子
太阳男子 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:21

    Yet another option is to play on the Class/Method level allowed by the @Profile annotation. Not as flexible as implementing MyProfileCondition but quick and clean if it suits your case.

    e.g. this won't start when FAST & DEV are both active, but will if only DEV is:

    @Configuration
    @Profile("!" + SPRING_PROFILE_FAST)
    public class TomcatLogbackAccessConfiguration {
    
        @Bean
        @Profile({SPRING_PROFILE_DEVELOPMENT, SPRING_PROFILE_STAGING})
        public EmbeddedServletContainerCustomizer containerCustomizer() {
    
    0 讨论(0)
提交回复
热议问题