我想將我們的幾個駱駝應用程序移到Spring Boot。我發現的大多數例子都是使用java dsl。我們目前支持的應用程序都基於Spring XML。將駱駝Spring XML移動到Spring Boot
我應該採取哪些步驟將這些應用程序遷移到Spring Boot。如果我使用FatJarRouter,我的理解是駱駝上下文已經被自動配置,所以在我看來,我應該能夠在spring xml中定義路由。
@SpringBootApplication
@ImportResource("classpath:camel-context.xml")
public class CamelApplication extends FatJarRouter {
public static void main(String[] args) {
SpringApplication.run(CamelApplication.class, args);
}
@Bean
String myBean() {
return "I'm Spring bean!";
}
}
駱駝的context.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<routes xmlns="http://camel.apache.org/schema/spring">
<route id="test">
<from uri="timer://trigger"/>
<transform>
<simple>ref:myBean</simple>
</transform>
<to uri="log:out"/>
</route>
</routes>
</beans>
異常
2015-11-13 15:59:13.734 WARN 2156 --- [on(5)-127.0.0.1] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate BeanDefinitionParser for element [routes]
Offending resource: class path resource [camel-context.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.fatal(FailFastProblemReporter.java:60) ~[spring-beans-4.2.2.RELEASE.jar:na]
at org.springframework.beans.factory.parsing.ReaderContext.fatal(ReaderContext.java:68) ~[spring-beans-4.2.2.RELEASE.jar:na]
是的,我們應該讓這更容易。我已經登錄了一張票:https://issues.apache.org/jira/browse/CAMEL-9325 –
我還應該使用FatJarRouter嗎? – zachariahyoung