title: How to use a properties file in Spring beans XML file?
body: <p>I have some properties files that I'd like to make available in the Spring XML config files. For example, in <code>hello.xml</code>:</p>
  
  <pre><code>&lt;bean id="theFoo" class="learnspring.Foo"&gt;
      &lt;property name="color" value="${foo.color}"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>In Java code:</p>
  
  <pre><code>ApplicationContext ac = new ClassPathXmlApplicationContext("hello.xml");
  File props = new File("path/to/hello.properties");
  File moreProps = new File("path/to/more.properties");
  // What to do here?
  Foo foo = (Foo)ac.getBean("theFoo");
  System.out.println(foo.getColor());
  </code></pre>
  
  <p>In <code>hello.properties</code>:</p>
  
  <pre><code>foo.color = blue
  </code></pre>
  
  <p>How do I make the properties files available to the Spring object definitions?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I'm porting some old Spring code. (Version 2.5) It looked sort of like this:</p>
  
  <pre><code>XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource(xmlFile));
  PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
  cfg.setLocations(new Resource[] {
      new ClassPathResource(propsResourcePath),
      new FileSystemResource(propsFile)) });
  
  cfg.postProcessBeanFactory(factory);
  new GenericApplicationContext(factory);
  </code></pre>
  
  <p>This code was marked deprecated, and I was having other problems, so I tried to port it to the new way.</p>