【问题标题】:<context:property-placeholder loading from the filesystem<context:property-placeholder 从文件系统加载
【发布时间】:2013-06-22 14:23:59
【问题描述】:
<context:property-placeholder ignore-unresolvable="true" location="classpath:test.properties" />

上述从 contex:property-placeholder 加载属性文件的方法工作得很好。我想要做的是从文件系统加载属性文件。

假设我在 C 盘 C:\spring\test.properties 中有文件。在这里如何使用context:property-placeholder 加载文件。

【问题讨论】:

    标签: spring properties


    【解决方案1】:

    使用file: URL 而不是classpath: 一个

    <context:property-placeholder ignore-unresolvable="true"
         location="file:/C:/spring/test.properties" />
    

    【讨论】:

      【解决方案2】:

      从文件系统(外部位置)为 Web 应用程序(基于 Spring)提供属性

      1) 将应用程序根 xml 中的占位符指定为

      2)在服务器的context.xml中定义环境名称为“config”并给出文件路径

      spring.xml

      文件:#{contextJndi.lookup('java:comp/env/config')}

      context.xml

      环境名称="config" override="false" type="java.lang.String" value="D:\config.properties"/>

      【讨论】:

        猜你喜欢
        • 2012-11-23
        • 1970-01-01
        • 2013-02-03
        • 2011-11-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-05-01
        • 1970-01-01
        相关资源
        最近更新 更多