【发布时间】:2016-12-17 05:14:28
【问题描述】:
如果当前配置文件不是数组之一,我想从自动装配候选者中排除 bean,如下所示:
@Component
@ActiveProfiles(value = {"!profile_1", "!profile_2"})
public class MyComponentImpl implements MyComponent
@Component
public class MyComponentDummy implements MyComponent
但是当我尝试通过 @ActiveProfiles 注释来执行此操作时,似乎没有排除 bean 并且我得到了 expected single matching bean but found 2。
我是否遗漏了什么,或者那样做是不可能的,必须用类似的东西来完成
@ActiveProfiles(value = {"profile_3", "!profile_4", ... })
我的spring版本是4.2.2
【问题讨论】: