title: Spring Boot does not load application.properties
body: <p>I am trying to load spring boot application.properties into java config class. But when I try to use the values, it is returning as null. I have followed everything as per online tutorials but not sure why it wont work. please guide me on this. </p>
  
  <p><strong>Application component Scan in XML File</strong> </p>
  
  <pre><code>&lt;context:component-scan base-package="com.saimuga.abp"&gt;&lt;/context:component-scan&gt;
  </code></pre>
  
  <p><strong>Application Entry point - Command Line runner</strong></p>
  
  <pre><code>@SpringBootApplication
  public class FileUploadApplication implements CommandLineRunner{
  
  public static void main(String[] args) {
      SpringApplication.run(FileUploadApplication.class, args);
  }
  
     //access command line arguments
  
  
  
  
  @Override
  public void run(String... args) throws Exception {
  
      System.out.println("args");
      System.out.println(args[0]);
  
  
      ApplicationContext ctx = new ClassPathXmlApplicationContext(
              "ABPBatchInfrastructure.xml",
              "FileUploadApp.xml"
      );
  
      JobLauncher jobLauncher = ctx.getBean(JobLauncher.class);
      Job job = ctx.getBean(Job.class);       
  
      /*
       * jobLauncher.run(job, new JobParametersBuilder().addString("inputResource",
       * "file:./products.zip") .addString("targetDirectory",
       * "./importproductsbatch/").addString("targetFile", "products.txt")
       * .addString("date", "2020-06-02").toJobParameters());
       */
  
      jobLauncher.run(job,
              new JobParametersBuilder().addString("inputResource", "file:./products.zip")
                      .addString("targetDirectory", "./importproductsbatch/").addString("targetFile", "products.txt")
                      .addString("date", "2034-09-30").toJobParameters());
  
  
  
  }
  
  }
  </code></pre>
  
  <p><strong>Environment Config Class</strong></p>
  
  <pre><code>@ConfigurationProperties(prefix = "notification")
  @Configuration("envProperties")
  public class NotifyYaml {
  
  private String test;
  
  public NotifyYaml() {
  
  }
  
  
  /**
   * @return the test
   */
  public String getTest() {
      return test;
  }
  
  /**
   * @param test the test to set
   */
  public void setTest(String test) {
      this.test = test;
  }
  
  
  }
  </code></pre>
  
  <p><strong>This is where I call Environment values</strong></p>
  
  <pre><code>public class ProductJdbcItemWriter implements ItemWriter&lt;Product&gt; {
  
  private static final String INSERT_PRODUCT = "insert into product (id,name,description,price) 
  values(?,?,?,?)";
  
  private static final String UPDATE_PRODUCT = "update product set name=?, description=?, price=? where 
  id = ?";
  
  private JdbcTemplate jdbcTemplate;
  
  @Autowired
  private NotifyYaml envProperties;
  
  public ProductJdbcItemWriter(DataSource dataSource) {
      System.out.println("cxf");
      this.jdbcTemplate = new JdbcTemplate(dataSource);
  }
  
  /* (non-Javadoc)
   * @see org.springframework.batch.item.ItemWriter#write(java.util.List)
   */
      public void write(List&lt;? extends Product&gt; items) throws Exception {
      System.out.println("cxf ProductJdbcItemWriter starts ");
      System.out.println(envProperties.getTest());
      for(Product item : items) {
          int updated = jdbcTemplate.update(UPDATE_PRODUCT,
              item.getName(),item.getDescription(),item.getPrice(),item.getId()
          );
          if(updated == 0) {
              jdbcTemplate.update(
                  INSERT_PRODUCT,
                  item.getId(),item.getName(),item.getDescription(),item.getPrice()
              );  
          }                               
          System.out.println("cxf ProductJdbcItemWriter ends ");
      }
      }
  
      }
  </code></pre>
  
  <p><strong>Added Properties File below</strong> </p>
  
  <pre><code>notification.test=test
  spring.main.allow-bean-definition-overriding=true
  spring.batch.job.enabled=false
  spring.datasource.username=postgres
  spring.jmx.enabled=false
  spring.jmx.default-domain=abpservice
  endpoints.jmx.domain=abpservice
  endpoints.jmx.domain.unique-names=true
  spring.application.admin.enabled=true
  </code></pre>
  
  <p>spring.application.admin.jmx-name=org.springframework.boot:type=Admin,name=SpringApplication </p>