簡體   English   中英

Spring CamelContext無法解析占位符

[英]Spring CamelContext Could not resolve placeholder

在我的應用我想從我的application.properties填補someData端點URL,並使用myEndpoint前徹底填補header.nameheader.myId。

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后我收到錯誤:

信息:初始化Spring root WebApplicationContext lis 07,2013 3:57:44 PM org.apache.catalina.core.StandardContext listenerStart SEVERE:將上下文初始化事件發送到類org.springframework.web.context.ContextLoaderListener org.springframework的偵聽器實例的異常.beans.factory.BeanDefinitionStoreException:在null中定義名稱為'myEndpoint'的bean定義無效:無法解析字符串值中的占位符'header.name':“http4:... myUrl ... / $ {header.name} / {{someData}} / $ {} header.myId”

我的臨時解決方案:我將header.nameheader.myId添加到application.properties(其中someData是)並且它再次起作用,但我知道不應該這樣做。 任何想法如何在不將這些值寫入屬性的情況下修復它?

這是Spring Framework的一個限制。 我們在Apache Camel網站上的常見問題解答中解釋了這一點以及您可以做些什么: http//camel.apache.org/how-do-i-use-spring-property-placeholder-with-camel-xml.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM