我正在OSGi-inf / blueprint /下的context.xml中加载cfg文件在我的context.xml文件中:
...
<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]
这将正确加载jdbc env属性,并将其注入context.xml中(稍后将testValue注入Java类中,这非常有用)]
我的问题是每当我删除此代码时
`<ext:property-placeholder placeholder-prefix="$sys["
placeholder-suffix="]" />`
我替换
testValue=$sys[jdbcUrl]
with
testValue=${project.version}
现在我的行为与以前不同,未加载project.version,testValue保持为空我应该怎么做才能正确注入${projetc.version}
?
ext:property-placeholder定义意味着您可以使用$ sys []引用任何系统属性。
因此要访问属性project.version,请尝试:$ sys [project.version]。当然,要使此工作有效,您必须在例如surefire配置中提供系统属性。