title: How to read application.properties in utils class
body: <p>I am writing a REST service using Spring Boot.</p>
  
  <p>Method in my rest service calls a util class and this util class needs to refer certain properties defined in the application.properties</p>
  
  <p>I user @Value and it didnt work inside the util class, where as it works in my REST service class.</p>
  
  <p>My REST service: ReportsController.java</p>
  
  <pre><code>@RestController
  @RequestMapping("/api/v1")
  public class ReportsController{
  
      @Value("${report.path}")
      private String reportPath;
  
      @GetMapping
      @RequestMapping("/welcome")
      public String retrieveWelcomeMessage() {
          return new ExcelFileUtil().test();
      }
      @GetMapping
      @RequestMapping("/welcome1")
      public String retrieveWelcomeMessage() {
          return reportPath;
      }
  }
  </code></pre>
  
  <p>My Utils class: MyUtil.java</p>
  
  <pre><code> public class  MyUtil{
  
       @Value("${report.path}")
       private String reportPath;
  
      public String test()
       {
           return reportPath;
       } 
   }
  </code></pre>
  
  <p>I am getting the value from application.properties is printed for <a href="http://localhost:8080/api/v1/welcome1" rel="nofollow noreferrer">http://localhost:8080/api/v1/welcome1</a>
  But getting blank for <a href="http://localhost:8080/api/v1/welcome" rel="nofollow noreferrer">http://localhost:8080/api/v1/welcome</a></p>
  
  <p>How to make the application.properties readable inside the MyUtil.java?</p>