In my Spring-Boot-App I want to conditionally declare a Bean, depending on (un)loaded spring-profiles.
The conditon:
Profile "a" NOT loaded
AND
Profile "b" NOT loaded
My solution so far (which works):
@Bean
@ConditionalOnExpression("#{!environment.getProperty('spring.profiles.active').contains('a') && !environment.getProperty('spring.profiles.active').contains('b')}")
public MyBean myBean(){/*...*/}
Is there a more elegant (and shorter) way to explain this condition?
Especially I want to get rid of the usage of Spring Expression Language here.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…