我的 TestSuite 有两种配置,它们为注入提供了不同的 bean。只要我使用注释设置我的个人资料,这就会起作用。
@ActiveProfiles( profiles={"a"})
和@ActiveProfiles( profiles={"b"})
但我似乎无法从属性源文件中设置它
我的注释看起来像
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AConfig.class, BConfig.class })
@PropertySource("classpath:/application.properties")
@TestPropertySource(locations = {"classpath:/application.properties"})
public abstract class AbstractTestIT {
...
}
的内容application.properties
是
spring.profiles.active="a"
结果导致不满意的依赖
正如上面提到的设置@ActiveProfiles
一样,并且使用了正确的被使用。
几乎就好像 PropertySource 和/或 TestPropertySource 不适用@RunWith(SpringJUnit4ClassRunner.class)