Reputation: 373
I've tried looking for an example of using the @Value annotation in Spring 3 to read values from a properties file using Spring EL but I haven't found a good example.
Here are some of the constituent pieces I've seen to achieve this except I don't know how all of these work together to read from a properties file
<util:properties id="ewConfiguration" location="classpath:ew.properties"/>
Now, how do I use this in my class to retrieve values from the ew.properties file to bind them to instance variables ?
For instance, if there exists a property url=www.google.com
and I have
@Configuration
class AppConfig {
@Value("???")
private String url //what do I use in the place of the ??? to bind the value of the url property
// in the properties file to this instance variable ?
}
Upvotes: 1
Views: 9286
Reputation: 160191
This example should be enough to get you started.
Nutshell Reference the property file's values like this:
@Value("#{ewConfiguration['url']}")
private String url;
Upvotes: 4