I am using Java 8 on spring framework. I have a properties file which has "=" separated values in it. I am trying to load the values of the properties file into a Property directly using spring annotation. For example : my Application.properites has:
cat=250
dog=560
lama=1000
donkey=650
And I have declared this properties file in my context.xml as :
<util:properties id="app_props"
location="classpath*:/application.properties" />
Now in my main class I am trying to load all of the values in Application.properites into
private Properties properties;
So that properties.getProperty("cat") will return "250"
Not sure how to do it. May I get any help on that?
properties
with@Resource(name="app_props")
? Theutil:properties
is not quite the correct way to initialize/load your "properties"; I would recommend you to look intocontext:property-placeholder
, and then useEnvironment
or@Value
. – x80486