title: creating and access properties file in spring mvc
body: <p><a href="https://stackoverflow.com/questions/10044789/accessing-application-properties-in-spring-mvc">read this article on SO</a>, and had some clarifying questions.</p>
  
  <p>I put my config.properties under src/main/resources</p>
  
  <p>In <code>spring-servlet.xml config file</code></p>
  
  <p>I added the following:</p>
  
  <pre><code>&lt;context:property-placeholder location="classpath:config.properties"/&gt;
  </code></pre>
  
  <p>In my business layer, I am trying to access it via</p>
  
  <pre><code>@Value("${upload.file.path}")
  private String uploadFilePath;
  </code></pre>
  
  <p>Eclipse shows error:</p>
  
  <pre><code>The attribute value is undefined for the annotation type Value
  </code></pre>
  
  <p>Can i not access the property in the business layer or are property files only read in the controller?</p>
  
  <p>UPDATE::
  src/main/java/com.companyname.controllers/homecontroller.java</p>
  
  <pre><code>public String home(Locale locale, Model model) {
      MyServiceObject myObj = new MyServiceObject();
      System.out.println("Property from my service object: = " + myObj.PropertyValue());
  
      if(myObj.PerformService())
      {
        ///
      }
  }
  </code></pre>
  
  <p>src/main/java/com.companyname.services/MyService.java</p>
  
  <pre><code>public class MyServiceObject {
  
      @Value("${db.server.ip}")
      private String _dbServerIP;
  
  
      public String PropertyValue() {
  
          return _dbServerIPaseURL;
      }
  
  
  
  }
  </code></pre>
  
  <p><a href="http://www.finalconcept.com.au/article/view/spring-using-the-value-annotation" rel="nofollow noreferrer">Another site where I found the explanation</a></p>