Spring ApplicationContextInitializer and properties
<p>I am learning about ApplicationContextInitializer. 
I was reading an example as shown below which is part of a webapp setup</p>

<pre><code>public class MyApplicationContextInitializer implements ApplicationContextInitializer&lt;ConfigurableWebApplicationContext&gt;{
.....
.....
public void initialize(ConfigurableWebApplicationContext applicationContext)  {
String homeKey = ((ConfigurableWebApplicationContext)applicationContext).getServletContext().getInitParameter("homekey");
.................
...............
</code></pre>

<p>The corresponding web.xml</p>

<pre><code>...............
...............
    &lt;context-param&gt;
        &lt;param-name&gt;contextClass&lt;/param-name&gt;
        &lt;param-value&gt;
          org.springframework.web.context.support.AnnotationConfigWebApplicationContext
      &lt;/param-value&gt;
    &lt;/context-param&gt;
    &lt;context-param&gt;
        &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
        &lt;param-value&gt;com.xxx.config&lt;/param-value&gt;
    &lt;/context-param&gt;
    &lt;context-param&gt;
        &lt;param-name&gt;contextInitializerClasses&lt;/param-name&gt;
        &lt;param-value&gt;com.xxxx.MyApplicationContextInitializer&lt;/param-value&gt;
    &lt;/context-param&gt;
    &lt;context-param&gt;
        &lt;param-name&gt;homekey&lt;/param-name&gt;
        &lt;param-value&gt;yyyyy&lt;/param-value&gt;
    &lt;/context-param&gt;
.............
...............
</code></pre>

<p>I want to duplicate this behavior in NON webapp application, more for learning purposes.</p>

<p>I have modified the MyApplicationContextInitializer as follows</p>

<pre><code>public class MyApplicationContextInitializer implements ApplicationContextInitializer&lt;ConfigurableApplicationContext&gt;{
................
......................
public void initialize(ConfigurableApplicationContext applicationContext) {
............
.............
</code></pre>

<p>My question is how do I get the "homekey" without the web.xml. I am assuming I can use system properties or use a property file and call methods applicationContext.getEnvironment().getProperty or applicationContext.getResource(). Can I do this without system properties or property file. The web.xml did not use any property file. </p>