【问题标题】:Loading property file from filesystem using util:properties?使用 util:properties 从文件系统加载属性文件?
【发布时间】:2012-06-13 22:00:12
【问题描述】:

当我尝试使用 util:properties 从文件系统加载属性文件时,找不到该属性文件。我把它放在我的根驱动器和各种地方,但我似乎无法使用 util:properties 从文件系统加载属性文件。

可以这样做吗?

<util:properties id="configProperties" location="file:///d:/config.properties"/>

从类路径加载它可以正常工作。但我想配置应用程序,以便系统管理员可以更改属性。

<util:properties id="configProperties" location="classpath:/config.properties"/>

【问题讨论】:

    标签: spring configuration properties


    【解决方案1】:

    我在一个 Linux 项目中有这个,它工作正常:

    <util:properties id="jdbcConfiguration" location="file:///home/reporting/jdbc.properties"/>
    

    所以问题可能出在您指定路径的方式上。试试这个方法:

    <util:properties id="configProperties" location="file:d:/config.properties"/>
    

    【讨论】:

    • 感谢您的回复.. 我确定我昨天深夜尝试了这个.. 但我犯了一个错误:) 我在 2 个不同的 spring xml 文件中有 util:properties,都指向一个错误的位置..我清理了它,实施了你的建议,它工作得很好!
    猜你喜欢
    • 2012-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-10
    • 1970-01-01
    • 2017-08-01
    • 1970-01-01
    相关资源
    最近更新 更多