से वसंत संदर्भ के लिए लोड गुण लोड करें मैं एक वसंत कमांड लाइन प्रोग्राम लिखना चाहता हूं जिसे एक प्रॉपर्टी फ़ाइल के साथ प्रारंभ किया गया है जो कमांड लाइन पैरामीटर के रूप में पास किया गया है। वह कैसे किया जा सकता है?कमांड लाइन
शुरू वर्ग:
public static void main (String [] args) {
String configFilename = args[0];
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"classpath:/context/applicationContext.xml");
MyBean bean = ctx.getBean(MyBean.class);
bean.getStarted();
}
applicationContext.xml:
<context:property-placeholder location="CONFIGFILENAME" ignore-unresolvable="true"/>
कैसे मैं वास्तविक वसंत संदर्भ के लिए अपने मुख्य विधि से अधिक कॉन्फ़िग फ़ाइल नाम मिलता है तो यह है कि मैं सही लोड कर सकते हैं पर्यावरण निर्भर गुण?
आप संभवतः एक JVM तर्क के बजाय इस्तेमाल कर सकते हैं: http://stackoverflow.com/questions/5598217/how-do-i-read-jvm-arguments-in-the-spring-applicationcontext-xml – DB5