I want to write a spring command line program that is initialized with a property file which is passed as command line parameter. How can that be done?
Starting class:
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"/>
How do I get the config file name over from my main method to the actual spring context so that I can load the correct environment dependent properties?