<context:property-placeholder ignore-unresolvable="true" location="classpath:test.properties" />上面提到的从contex: property -placeholder加载属性文件的方法工作得很好。我想要做的是从文件系统加载属性文件。
假设我的文件在C盘C:\spring\test.properties中。在这里,我如何使用context:property-placeholder加载文件。
发布于 2013-06-26 01:16:50
使用file:地址而不是classpath:地址
<context:property-placeholder ignore-unresolvable="true"
location="file:/C:/spring/test.properties" />发布于 2014-07-10 22:15:00
从文件系统(外部位置)向web应用程序(基于Spring)提供属性
1)将应用程序根xml中的占位符指定为
2)在服务器的context.xml中将环境名称定义为"config“,并给出文件的路径
spring.xml
file:#{contextJndi.lookup('java:comp/env/config')}
context.xml
环境name="config“override="false”type="java.lang.String“config
https://stackoverflow.com/questions/17303261
复制相似问题