java spring - read properties file variable from xml -PropertyPlaceholderConfigurer

Java springframework xml configuration file - how to read properties file variables from spring xml :
We have to use PropertyPlaceholderConfigurer bean for this.

1).properties file location -

  • src/main/resource @ maven managed project
  • OR at classpath

2)The xml code to initialize/read properties file, 

I have a sample file at either of above location.

        <property name="locations" value="" />

3) file content -


4)Using this server.url at xml file :

We have to use - ${server.url}
eg :
<property name="serviceUrl" value="${server.url}testService" />


<sometag name="someName"> ${server.url} </sometag>

No comments :

Post a Comment

Your Comment and Question will help to make this blog better...