日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java camel from uri_java – 如何将Camel属性加载到Bean中?

發布時間:2025/3/20 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java camel from uri_java – 如何将Camel属性加载到Bean中? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我一直在閱讀關于Camel屬性的以下頁面:

http://camel.apache.org/using-propertyplaceholder.html并且還閱讀了“Camel In Action”一書.

我發現“Camel In Action”的第6章在定義Camel屬性方面非常有用,我可以從config.properties加載以下三個屬性:

config.timeout=10000

config.numSamples=1000

config.defaultViz=a

當我運行我的Java代碼時,我能夠在applicationContext.xml中的camel路由中看到以下三個值,如下面的線程#0消息所示:

14669 [Camel (HelloWorldContext) thread #0 - timer://hello.world.request.timer] INFO route1 - printing values read from config.properties file

14669 [Camel (HelloWorldContext) thread #0 - timer://hello.world.request.timer] INFO route1 - config.timeout= 10000

14669 [Camel (HelloWorldContext) thread #0 - timer://hello.world.request.timer] INFO route1 - config.numSamples= 1000

14670 [Camel (HelloWorldContext) thread #0 - timer://hello.world.request.timer] INFO route1 - config.defaultViz= a

但是,當我嘗試將變量{{config.defaultViz}}傳遞給我的SensorGenerator Java類中名為defaultViz的String,并打印該字符串時,我在控制臺上獲得“{{config.defaultViz}}”而不是包含的值在{{config.defaultViz}}內.

換句話說,這就是我在屏幕上看到的內容:

Returning List

defaultViz= {{config.defaultViz}}

但我真的想在屏幕上看到這個:

Returning List

defaultViz=a

那么我在applicationContext.xml中做錯了什么?

更新:問題是我需要在Spring和Camel之間添加一個Bridge,如上面引用的鏈接中所述.

這是我的UPDATED applicationContext.xml和橋:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:util="http://www.springframework.org/schema/util"

xsi:schemaLocation="

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd

http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" />

uri="timer://hello.world.request.timer?fixedRate=true&period={{config.timeout}}" />

class="org.apache.camel.component.properties.PropertiesComponent">

總結

以上是生活随笔為你收集整理的java camel from uri_java – 如何将Camel属性加载到Bean中?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。