最近在做spring集成camel的項目,查看了官網和博客等其他的文章,總結了spring集成camel時需要做的幾件事:
1.Adding Camel schema 在spring配置文件中添加spring集成camel需要的命名空間
2.Configure Routes in two ways:
2.1 Using Spring XML
2.2 Using Java Code
Adding Camel Schema:
<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">
添加Camel路由:
<camelContext id="camel5" xmlns="http://camel.apache.org/schema/spring">
</camelContext>
注意:
網上幾乎都是這種方式,我也按照這種方式試了一下午,始終沒有成功,一直報錯找不到 http://camel.apache.org/schema/spring 很是奇怪,直到後來才知道是導入jar包問題。導入jar如下:採用pom.xml方式
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.17.3<version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>2.17.3<version>
</dependency>
當然還需要添加spring的jar包才能運行的!!!!
參考官網:點擊打開鏈接