从春天注解配置初始化骆驼 [英] Initializing camel from Spring annotation config
问题描述
我想学习Spring和理解它是如何工作的。我按照配置Spring和骆驼一些教程,并产生了它的工作使用默认设置。
我现在试图尽可能的我的配置XML的文件到Java类转换。到目前为止,我已经成功地建立在Java类骆驼的路由(扩展SpringRouteBuilder和实施配置()),以及所有从我的弹簧配置文件中的豆(Bean->功能与@Bean)。我唯一缺少的部分是camelContext定义,开始我的骆驼路线(我想...)(?):
<骆驼:camelContext ID =camel5>
<骆驼:包装> net.krg.kneip.routing< /骆驼:包装>
< /骆驼:camelContext>
什么会这相当于非XML是什么?
不知道这会帮助,但这里是我的AppConfig类到目前为止: http://pastebin.com/vsRAbpK1
谢谢!
解决方案:
@Bean
公共CamelContext骆驼()抛出异常{
CamelContext camelContext =新DefaultCamelContext();
camelContext.addRoutes(新net.krg.kneip.routing.Routes());
camelContext.start();
返回camelContext;
}
CamelContext背景=新DefaultCamelContext();
我觉得这是你在找什么。
I am trying to learn Spring and understand how it works. I have followed some tutorials in setting up Spring and Camel, and have had it working using default setups.
I am now attempting to convert as much as possible of my configuration XML-files to Java-classes. So far I have been successful in creating the camel-routes in a Java-class (extending SpringRouteBuilder and implementing configure() ), and all the beans from my spring-configuration file (Bean->Function with @Bean). The only part I am missing is the camelContext definition (?) that starts my camel routes (I think...):
<camel:camelContext id="camel5">
<camel:package>net.krg.kneip.routing</camel:package>
</camel:camelContext>
What would the equivalent non-XML of this be?
Not sure if it will help, but here is my AppConfig class so far: http://pastebin.com/vsRAbpK1
Thanks!
SOLUTION:
@Bean
public CamelContext camel() throws Exception{
CamelContext camelContext = new DefaultCamelContext();
camelContext.addRoutes(new net.krg.kneip.routing.Routes());
camelContext.start();
return camelContext;
}
CamelContext context = new DefaultCamelContext();
I think this is what you're looking for.
这篇关于从春天注解配置初始化骆驼的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!