![](/img/trans.png)
[英]Using Spring @Profile to load log4j2 xml configuration instead of maven <profile>
[英]Load spring xml configuration according the profile
我知道我可以像这样从xml文件加载应用程序上下文:
ApplicationContext app = new ClassPathXmlApplicationContext("META-INF/applicationContext.xml");
但就我而言,这是无关紧要的。
在applicationContext.xml
我使用配置文件。
如何根据配置文件加载上下文?
您可以通过JVM属性设置配置文件
-Dspring.profiles.active = YOUR_PROFILE_NAMES_AS_COMMA_SEPARATED_LIST
然后,使用已使用JVM属性激活的bean创建Application Context。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.