Reading property file

I have an application.properties file where I have listed the “env.baseurl”.

I have another file “requestcall.xml” where this URL from properties file needs to be passed within the block for API (webservice).

There is a tag of in which I want to pass the URL. Could anyone please guide me, thanks in advance.

2
Leave a Reply

avatar
2 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Jason
Guest

Try this to read application properties xml using spring

@Value("${env.baseurl}")
private String envBaseURL;

Jason
Guest

To load these properties files in an application, we use PropertyPlaceholderConfigurer .
You need to configure your xml file to read the .propertiles file.

<bean id="propertyConfigurerService" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
   <property name="locations">
       <list>
           <value>classpath:application.properties</value>
       </list>
   </property>
</bean>

Now you need to read env.baseurl as per your requirement:

<bean class="your class">
  <property name="baseurl"><value>${env.baseurl}</value></property>
</bean>

I will advice to look into the beautiful article over Dzone, it will clear your doubts as certain.