I'm not 100%, but I think yours is @PropertySourcenot quite right. Instead
@PropertySource(value = "classpath:application.properties")
It should be simple:
@PropertySource("classpath:application.properties")
based on this:
Spring Documentation PropertySource
Also, based on the link above and since you mentioned you are converting to java configuration approach instead of xml, I think there might be a solution to your problem below:
${...} @Value. ${...} @Value PropertySource, PropertySourcesPlaceholderConfigurer. XML, @ Bean @Configuration. . " " @Configuration Javadoc " BeanFactoryPostProcessor-return @Bean " @Bean Javadoc .
, :
@Configuration
@PropertySource("classpath:/com/myco/app.properties")
public class AppConfig {
@Autowired
Environment env;
@Bean
public TestBean testBean() {
TestBean testBean = new TestBean();
testBean.setName(env.getProperty("testbean.name"));
return testBean;
}
}
, :
@Autowired
Environment env;
:
tr.setPassword(env.getProperty("rt.setPassword"));
.. . , . , .