简体   繁体   中英

Load spring xml configuration according the profile

I know that I can load application context from xml file like this:

ApplicationContext app = new ClassPathXmlApplicationContext("META-INF/applicationContext.xml");

But in my case it is irrelevent.

inside the applicationContext.xml I use profiles.

How can I load context according the profile ?

You can set the profile via an JVM property

-Dspring.profiles.active=YOUR_PROFILE_NAMES_AS_COMMA_SEPARATED_LIST

Then Application Context gets created with beans which you have activated using JVM property

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM