I am trying to autowire one of the configuration class but it is returning null. Can you please help me to figure out what I am doing wrong?
The configuration class looks like below -
package com.xyz.abc.mn.filereader.batch.config;
@Configuration
public class Xyz{
@Value("${property1:#{'09'}}")
private String property1;
...
...
//getters and setters
This is the Util class where I am trying to use the autowire -
package com.xyz.abc.mn.filereader.batch.util;
public class XyzUtil{
@Autowired
private Xyz xyz;
public boolean method1(){
xyz.getProperty1(); //Giving Null pointer exception as xyz is Null
...
...
My application class looks like below -
package com.xyz.abc.mn.filereader.batch.config;
@Configuration
@EnableBatchProcessing
@EnableAutoConfiguration
@ComponentScan(basePackages={"com.xyz.abc.mn.filereader.batch.*""})
@PropertySource(value="file:${props.file}")
public class MainApplication {
@Autowired
private JobBuilderFactory jobBuilderFactory;
@Autowired
private StepBuilderFactory stepBuilderFactory;
...
...
...