从.properties文件读取参数到.xml文件
作者:互联网
我有一个application.xml文件(directory = WEB-INF / application.xml)
我有一个jasperserver.properties文件(directory = WEB-INF / internal / jasperserver.properties)
这是在jasperserver.properties文件中
SERVICE_URL=http://b-reptest-lnx.nwu.ac.za:8026/jasperserver-pro/j_spring_cas_security
我想从application.xml文件中读取“SERVICE_URL”属性
我该怎么做呢 ?
解决方法:
在application.xml中使用PropertyPlaceholderConfigurer.
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:path/to/jasperserver.properties</value>
</property>
</bean>
加载属性文件.
然后在application.xml中使用${SERVICE_URL}来替换值:
<bean class="your class">
<property name="serviceURL"><value>${SERVICE_URL}</value></property>
</bean>
标签:xml,spring,jasper-reports,jasperserver 来源: https://codeday.me/bug/20190529/1177280.html