[英]How to replace text values in cfg files loaded in blueprint/context.xml
我正在我的 context.xml 在我的 context.xml 文件下的 OSGi-inf/blueprint/ 下加载一个 cfg 文件:
...
<cm:property-placeholder
persistent-id="com.lolo.${project.version}"
update-strategy="reload">
<cm:default-properties>
<cm:property name="testValue" value="" />
</cm:default-properties>
</cm:property-placeholder>
<ext:property-placeholder placeholder-prefix="$sys["
placeholder-suffix="]" />
在我的 cfg 文件中,我得到:
testValue=$sys[jdbcUrl]
this loads correctly the jdbc env property and injects it in the context.xml ( the testValue will be later injected in a Java class, which is is very useful)
我的问题是每当我删除此代码时
`<ext:property-placeholder placeholder-prefix="$sys["
placeholder-suffix="]" />`
我替换
testValue=$sys[jdbcUrl]
with
testValue=${project.version}
现在我没有得到与以前相同的行为,未加载 project.version 测试值保持为空我应该怎么做才能正确注入${projetc.version}
?
ext:property-placeholder 定义意味着您可以使用 $sys[] 引用任何系统属性。
所以要访问属性 project.version 尝试:$sys[project.version]。 当然,要完成这项工作,您必须提供系统属性,例如在 surefire 配置中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.