Apache camel 是否可以在上下文中同时使用routeContextRef和dataFormats元素?

Apache camel 是否可以在上下文中同时使用routeContextRef和dataFormats元素?,apache-camel,Apache Camel,当我尝试这样做时,我得到: Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 35 in XML document from class path resource [META-INF/spring/camel-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNu

当我尝试这样做时,我得到:

Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 35 in XML document from class path resource [META-INF/spring/camel-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 35; columnNumber: 55; cvc-complex-type.2.4.a: Invalid content was found starting with element 'routeContextRef'. One of '{"http://camel.apache.org/schema/spring":redeliveryPolicyProfile, "http://camel.apache.org/schema/spring":onException, "http://camel.apache.org/schema/spring":onCompletion, "http://camel.apache.org/schema/spring":intercept, "http://camel.apache.org/schema/spring":interceptFrom, "http://camel.apache.org/schema/spring":interceptSendToEndpoint, "http://camel.apache.org/schema/spring":route}' is expected.
通过检查模式,显然不可能在可以使用dataFormat的routeContext中定义路由,因为dataFormats元素必须在routeContextRef元素之后

我是否需要放弃routeContext组织方法,将所有路由放在一个文件中

这里是骆驼上下文的一个稍微弯曲的版本。我需要能够在cContext中使用json

<?xml version="1.0" ?>
<beans
   xmlns="http://www.springframework.org/schema/beans"  
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
 http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
    <property name="connectionFactory">
        <bean class="org.apache.activemq.ActiveMQConnectionFactory">
            <property name="brokerURL" value="tcp://localhost:61616"/>
        </bean>
    </property>
</bean>

<import resource="classBeanDefs.xml"/>
<import resource="a.xml"/>
<import resource="b.xml"/>
<import resource="c.xml"/>

<camelContext id="camel" trace="false" xmlns="http://camel.apache.org/schema/spring">
    <propertyPlaceholder id="properties"
                         location="classpath:route.properties"
                         xmlns="http://camel.apache.org/schema/spring"/>

    <dataFormats>
        <json id="json" library="Jackson"/>
    </dataFormats>

    <routeContextRef ref="aContext"/>
    <routeContextRef ref="bContext"/>
    <routeContextRef ref="cContext"/>
</camelContext>

</beans>


当我尝试将dataFormats元素添加到routeContext时,我会遇到类似的错误,模式显然不赞成的。

你应该在数据格式之前有你的routeContextRef。

你应该在数据格式之前有你的routeContextRef。

给我们看看你的
context.xml
。史蒂夫找到解决方案了吗?给我们看看你的
context.xml
。史蒂夫找到解决方案了吗?对,这就是模式所要求的。但在这种情况下,它不适用于RouteContext中定义的路由。是的,这很可能是不可能的。我们有一张改进的票:似乎我甚至不能在标签之前。我的context.xmlRight中没有任何数据格式,这是模式要求的。但在这种情况下,它不适用于RouteContext中定义的路由。是的,这很可能是不可能的。我们有一张改进的票:似乎我甚至不能在标签之前。我的context.xml中没有任何数据格式