Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reading parameter from .properties file to .xml file

I have a application.xml file (directory = WEB-INF/application.xml)

and I have a jasperserver.properties file (directory = WEB-INF/internal/jasperserver.properties)

This is in the jasperserver.properties file

SERVICE_URL=http://b-reptest-lnx.nwu.ac.za:8026/jasperserver-pro/j_spring_cas_security

I want to read that "SERVICE_URL" property from the application.xml file

How do I do this ?

like image 973
Andre Avatar asked Mar 22 '23 21:03

Andre


1 Answers

use PropertyPlaceholderConfigurer in application.xml.

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="location">
    <value>classpath:path/to/jasperserver.properties</value>
  </property>
</bean>

to load properties file. Then use ${SERVICE_URL} in your application.xml to substitute values:

<bean class="your class">
  <property name="serviceURL"><value>${SERVICE_URL}</value></property>
</bean>
like image 183
Luca Basso Ricci Avatar answered Apr 01 '23 09:04

Luca Basso Ricci