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 config.properties file at either of above location.
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="classpath:config.properties" />
</bean>
3)config.properties file content -
server.url=http://localhost:8080/testapp/
4)Using this server.url at xml file :
We have to use - ${server.url}
eg :<property name="serviceUrl" value="${server.url}testService" />
-OR
<sometag name="someName"> ${server.url} </sometag>
No comments:
Post a Comment
Your Comment and Question will help to make this blog better...