在我的camel / blueprint项目中,我在blueprint.xml中定义了一个property-placeholder :
<cm:property-placeholder id="props.placeholder" persistent-id="props.blueprint"> <cm:default-properties> <cm:property name="app.name" value="app-service" /> </cm:default-properties> </cm:property-placeholder>有了这个,我可以在java中注入属性(例如驼峰路线):
@Value("${app.name}") private String name;现在我需要引入第二个属性占位符:
<cm:property-placeholder id="container_specific.placeholder" persistent-id="container_specific.blueprint" placeholder-prefix="%%{" placeholder-suffix="}%%"> <cm:default-properties> <cm:property name="service.port" value="1234"/> </cm:default-properties> </cm:property-placeholder>但是如何使用/注入第二个持有者的属性到java? @Value("%%{service.port}%%)不起作用。
In my camel/blueprint project i defined a property-placeholder in the blueprint.xml:
<cm:property-placeholder id="props.placeholder" persistent-id="props.blueprint"> <cm:default-properties> <cm:property name="app.name" value="app-service" /> </cm:default-properties> </cm:property-placeholder>With this in place i can inject the properties in java (e.g. camel routes):
@Value("${app.name}") private String name;Now i need to introduce a 2nd property placeholder:
<cm:property-placeholder id="container_specific.placeholder" persistent-id="container_specific.blueprint" placeholder-prefix="%%{" placeholder-suffix="}%%"> <cm:default-properties> <cm:property name="service.port" value="1234"/> </cm:default-properties> </cm:property-placeholder>But how to use/inject property from the 2nd holder into java? @Value("%%{service.port}%%) does not work.
最满意答案
阅读文档: http : //camel.apache.org/using-propertyplaceholder.html
有一个示例显示如何通过id引用蓝图,因此只需配置Camel以引用这两个ID
<propertyPlaceholder id="properties" location="blueprint:props.placeholder,blueprint:container_specific.placeholder">Read the documentation: http://camel.apache.org/using-propertyplaceholder.html
There is an example which shows how to refer to the blueprint by id, so just configure Camel to refer to those two ids
<propertyPlaceholder id="properties" location="blueprint:props.placeholder,blueprint:container_specific.placeholder">更多推荐
发布评论