【发布时间】:2013-11-12 14:07:48
【问题描述】:
在我的应用程序中,我想用 application.properties 中的 someData 填充端点 url,并彻底填充 header.name 和 header.myId在使用 myEndpoint 之前。
my_bean.xml:
<camel:camelContext id="camel" xmlns="http://camel.apache.org/schema/spring" >
<propertyPlaceholder id="properties" location="ref:myProps"/>
<endpoint id="myEndpoint" uri="...myUrl.../${header.name}/{{someData}}/${header.myId}"/>
<route id="myRoute" trace="true">
...
</route>
</camel:camelContext>
它工作得很好,我创建了测试,一切都很棒我将 my_bean.xml 添加到 web.xml 以便使用一个类,我在另一个类中使用这个端点。将其添加到 web.xml 后出现错误:
INFO:初始化 Spring 根 WebApplicationContext lis 07, 2013 下午 3:57:44 org.apache.catalina.core.StandardContext listenerStart 严重:向侦听器发送上下文初始化事件的异常 类的实例 org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanDefinitionStoreException: 中定义的名称为“myEndpoint”的无效 bean 定义 null:无法解析占位符“header.name” 字符串值: "http4:...myUrl.../${header.name}/{{someData}}/${header.myId}"
我的临时解决方案:我将 header.name 和 header.myId 添加到 application.properties(someData 所在的位置)并且它再次工作但我知道不应该这样做。 知道如何在不将这些值写入属性的情况下修复它吗?
【问题讨论】:
标签: java spring apache-camel