我想转义我的 Spring 属性文件以获取我的 bean 属性:${ROOTPATH}/relativePath
我有一个简单的 Spring 配置文件,其中包含:
<context:property-placeholder location="classpath:myprops.properties" />
<bean id="myBean" class="spring.MyBean">
<property name="myProperty" value="${myproperty}" />
</bean>
myprops.properties
包含:myproperty=\${ROOTPATH}/relativePath
上述设置返回:无法解析占位符“ROOTPATH”。我尝试了很多可能的语法,但找不到正确的语法。
最佳答案
而不是 ${myproperty}
使用 #{'$'}{myproperty}
.只需更换 $
与 #{'$'}
.
关于spring - Spring 属性文件中的转义属性引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13162346/