如何在 spring 中通过注释设置 Activity 配置文件?
例如:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { ApplicationConfig.class }, loader = AnnotationConfigContextLoader.class)
@ActiveProfiles( profiles = {ApplicationProfiles.TEST} )
public class CacheManagerTest {
...
}
对于 JUnit 测试,这很完美,但我如何初始化生产应用程序上下文? (我没有任何主要方法/类)
最佳答案
您可以在运行时使用 spring.profiles.active
传入 Activity 配置文件属性:
-Dspring.profiles.active="profile1,profile2"
见 SpringSource blog post关于简介的介绍。
关于java - 如何在 Spring 通过注释设置 Activity 配置文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17315379/