加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

从.properties文件读取参数到.xml文件

发布时间:2020-12-16 23:07:15 所属栏目:百科 来源:网络整理
导读:我有一个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
我有一个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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读