Spring 属性文件中的转义属性引用 [英] Escape property reference in Spring property file

查看:32
本文介绍了Spring 属性文件中的转义属性引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想转义我的 Spring 属性文件以进入我的 bean 属性:${ROOTPATH}/relativePath

I want to escape my Spring propeties file in order to get in my bean property: ${ROOTPATH}/relativePath

我有一个简单的 Spring 配置文件,其中包含:

I have a simple Spring config file that contains:

<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".我尝试了很多可能的语法,但没有找到合适的.

The above setup returns: Could not resolve placeholder 'ROOTPATH'. I tried a lot of possible syntaxes but was not able to find the right one.

推荐答案

使用 #{'$'}{myproperty} 代替 ${myproperty}.只需将 $ 替换为 #{'$'}.

Instead of ${myproperty} use #{'$'}{myproperty}. Simply replace $ with #{'$'}.

这篇关于Spring 属性文件中的转义属性引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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