我在我的context.xml文件中的OSGi-inf/blueprint/下的context.xml中加载了一个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]这将正确地加载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}?
发布于 2019-10-22 16:16:42
属性占位符定义意味着您可以使用$sys[]引用任何系统属性。
因此,要访问属性project.version,请尝试:$sysproject.version。当然,要实现这一点,您必须提供系统属性,例如,在surefire配置中。
https://stackoverflow.com/questions/58217033
复制相似问题