I\'m reading properties file using context:property-placeholder. How can I access them programatically (@Value doesn\'t work - I d
We use the following approach to access properties for our applications
Then you have the luxury of just autowiring properties into beans using a qualifier.
@Component
public class PropertyAccessBean {
private Properties properties;
@Autowired
@Qualifier("appProperties")
public void setProperties(Properties properties) {
this.properties = properties;
}
public void doSomething() {
String property = properties.getProperty("code.version");
}
}
If you have more complex properties you can still use ignore-resource-not-found and ignore-unresolvable. We use this approach to externalise some of our application settings.