<context:property-placeholder 从文件系统加载 [英] <context:property-placeholder loading from the filesystem

查看:54
本文介绍了<context:property-placeholder 从文件系统加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

Above mentioned way of loading the property files from contex:property-placeholder works just fine. What I want to do is loading the property file from the file system.

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

Let's say I have the file in C drive C:\spring\test.properties. Here how can I load the file using context:property-placeholder.

推荐答案

使用 file: URL 而不是 classpath: one

Use a file: URL instead of a classpath: one

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

这篇关于&lt;context:property-placeholder 从文件系统加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆