title: Reading external properties file
body: <p>I am working with Spring MVC to develop this application. I am supposed to read from an external .properties file.</p>
  
  <p>mvc-dispatcher-servlet.xml</p>
  
  <pre><code> &lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
              &lt;property name="locations"&gt;
              &lt;list&gt;
                  &lt;value&gt;classpath:Host.properties&lt;/value&gt;
                  &lt;value&gt;file:///usr/pic1/JSONEditor/Host.properties&lt;/value&gt;
              &lt;/list&gt;
              &lt;/property&gt;
              &lt;property name="ignoreUnresolvablePlaceholders" value="true"/&gt;
              &lt;property name="ignoreResourceNotFound" value="true"/&gt;
          &lt;/bean&gt;
  
  &lt;bean id="dataSource" class="com.example.editor.Configuration"&gt;
             &lt;property name="hostURL" value="${url}" /&gt;
         &lt;/bean&gt;
  </code></pre>
  
  <p>Configuration.java</p>
  
  <pre><code>package com.example.editor;
  
  import org.springframework.beans.factory.annotation.Value;
  
  public class Configuration {
  
      @Value("$(url)")
      private String hostURL;
  
      public String getHostURL(){
          System.out.println("URL:"+this.hostURL);
          return this.hostURL;
      }
  
      public void setHostURL(String url){
          this.hostURL = url;
          System.out.println("URL:"+this.hostURL);
      }
  
  }
  </code></pre>
  
  <p>EditorController.java</p>
  
  <pre><code>package com.example.editor.controller;
  
  import java.io.IOException;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.ModelMap;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
  import com.example.editor.Configuration;
  
  
  
      @Controller
      @RequestMapping("/")
      public class EditorController {
  
          private static final String start = "Editor";
  
          @RequestMapping(value = "/", method = RequestMethod.GET)
          public String start(ModelMap model) throws IOException{
  
          Configuration confg = new Configuration();
          model.addAttribute("URL", confg.getHostURL());
  
              return start;
          }
  
      }
  </code></pre>
  
  <p>It is able to read the file and get the url when I launch the application but once I open it in the browser, hostURL=null.</p>
  
  <p>Can someone please point out what the mistake is?</p>