apche camel xml dsl获取路由定义在最新camel 3.19版本中抛出错误

tktrz96b  于 2022-11-07  发布在  Apache
关注(0)|答案(1)|浏览(164)

我一直在寻找一段时间来解决这个问题,但最终在这里问它,因为我找不到任何解决方案,到目前为止。我们有一个应用程序开发的apache Camel 与xml dsl定义,这是在旧版本的apache Camel 工作正常。我更新到最新版本3.19,并得到以下错误在部署的应用程序。

Caused by: org.xml.sax.SAXParseException; lineNumber: 35; columnNumber: 22; cvc-complex-type.3.2.2: Attribute 'uri' is not allowed to appear in element 'get'.

applicationContext.xml

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

    <camelContext
        xmlns="http://camel.apache.org/schema/spring">
        <rest path="/say">
            <get uri="/hello">
                <to uri="direct:hello" />
            </get>
            <get uri="/bye" consumes="application/json">
                <to uri="direct:bye" />
            </get>
            <post uri="/bye">
                <to uri="mock:update" />
            </post>
        </rest>
        <route>
            <from uri="direct:hello" />
            <transform>
                <constant>Hello World</constant>
            </transform>
        </route>
        <route>
            <from uri="direct:bye" />
            <transform>
                <constant>Bye World</constant>
            </transform>
        </route>
    </camelContext>
</beans>

路线的定义如official documentation所示。如有任何帮助,将不胜感激。

mdfafbf1

mdfafbf11#

自Camel版本3.16.0以来,uri属性已重命名为path,请参见此票证中的说明https://issues.apache.org/jira/browse/CAMEL-17673?focusedCommentId=17493997&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17493997

在3.16.0之前的camel版本中

请参阅https://camel.apache.org/schema/spring/camel-spring-3.15.0.xsd

<xs:complexType name="verbDefinition">
    <xs:complexContent>
        <xs:extension base="tns:optionalIdentifiedDefinition">
            <xs:sequence>
                <xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:param"/>
                <xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:responseMessage"/>
                <xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:security"/>
                <xs:choice>
                    <xs:element ref="tns:to"/>
                    <xs:element ref="tns:toD"/>
                    <xs:element ref="tns:route"/>
                </xs:choice>
            </xs:sequence>
            <xs:attribute name="method" type="xs:string">
                <xs:annotation>
                    <xs:documentation xml:lang="en">
                        <![CDATA[ The HTTP verb such as GET, POST, DELETE, etc. ]]>
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>
            <xs:attribute name="uri" type="xs:string"> <!--*****HERE******-->
                <xs:annotation>
                    <xs:documentation xml:lang="en">
                        <![CDATA[ Uri template of this REST service such as /{id}. ]]>
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>
自Camel 3.16.0版起

请参阅https://camel.apache.org/schema/spring/camel-spring-3.16.0.xsd

<xs:complexType abstract="true" name="verbDefinition">
    <xs:complexContent>
        <xs:extension base="tns:optionalIdentifiedDefinition">
            <xs:sequence>
                <xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:param"/>
                <xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:responseMessage"/>
                <xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:security"/>
                <xs:element ref="tns:to"/>
            </xs:sequence>
            <xs:attribute name="path" type="xs:string">
                <xs:annotation>
                    <xs:documentation xml:lang="en">
                        <![CDATA[ The path mapping URIs of this REST operation such as /{id}. ]]>
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>

遗憾的是,Camel文档尚未更新以反映此更改,示例仍然使用uri属性:https://camel.apache.org/manual/rest-dsl.html#_rest_dsl_with_xml_dsl

相关问题