title: Load properties for spring context from command-line
body: <p>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?</p>
  
  <p>Starting class:</p>
  
  <pre><code>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();
  }
  </code></pre>
  
  <p>applicationContext.xml:</p>
  
  <pre><code>&lt;context:property-placeholder location="CONFIGFILENAME" ignore-unresolvable="true"/&gt;
  </code></pre>
  
  <p>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?</p>