317.2. 添加 Camel Schema
对于 Camel 1.x,您需要使用以下命名空间:
http://activemq.apache.org/camel/schema/spring
使用以下架构位置:
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
您需要将 Camel 添加到 schemaLocation
声明中
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
因此,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">
317.2.1. 使用 camel: namespace
或者您可以在 XML 声明中引用 camel XSD:
xmlns:camel="http://camel.apache.org/schema/spring"
- 因此,声明为:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring" 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: 命名空间前缀,您可以省略内联命名空间声明:
<camel:camelContext id="camel5"> <camel:package>org.apache.camel.spring.example</camel:package> </camel:camelContext>