有没有一种方法可以相对于 Spring 的上下文文件本身在文件系统(而不是类路径)上引用属性文件?
我想做的是:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<!-- I want the below to be relative to this context XML file. -->
<value>app.properties</value>
</list>
</property>
</bean>
我在想象像 ${contextpath}
这样的东西,我可以在上面的“app.properties”之前加上它,但找不到任何有用的东西。
谢谢。
最佳答案
您可以通过 classpath:
前缀引用类路径上的属性:
<value>classpath:app.properties</value>
关于java - 在 Spring 中指定相对于上下文 XML 的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2591168/