I am trying to use the @Value annotation on a variable to assign a value, but the value getting assigned is null. What am I doing wrong? I am using the java spring configuration using @Configuration. I am also using @PropertySource to point to a properties file.
@Configuration
@PropertySource("classpath:application.properties")
public class SpringConfiguration {
@Value("${app_prop_1}") Integer aValue;
@Bean
public Integer getInteger() {
return new Integer(aValue); // throws NullPointerException
}
}
The application.properties files is in the maven resources folder of project. It has following content:
app_prop_1=2000