[英]Load spring xml configuration according the profile
I know that I can load application context from xml file like this: 我知道我可以像这样从xml文件加载应用程序上下文:
ApplicationContext app = new ClassPathXmlApplicationContext("META-INF/applicationContext.xml");
But in my case it is irrelevent. 但就我而言,这是无关紧要的。
inside the applicationContext.xml
I use profiles. 在applicationContext.xml
我使用配置文件。
How can I load context according the profile ? 如何根据配置文件加载上下文?
You can set the profile via an JVM property 您可以通过JVM属性设置配置文件
-Dspring.profiles.active=YOUR_PROFILE_NAMES_AS_COMMA_SEPARATED_LIST -Dspring.profiles.active = YOUR_PROFILE_NAMES_AS_COMMA_SEPARATED_LIST
Then Application Context gets created with beans which you have activated using JVM property 然后,使用已使用JVM属性激活的bean创建Application Context。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.