You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Apache Camel 3.19版本XML DSL Get路由部署报错求助

问题解决:Camel 3.19升级后REST XML DSL的uri属性校验错误

错误原因

  1. Schema版本不匹配:配置中引用的Camel Spring Schema为3.18.0版本,但应用已升级至Camel 3.19,新版本Schema对REST DSL的元素属性定义做了变更,导致旧属性不符合新的校验规则。
  2. REST DSL语法变更:Camel 3.19开始,XML DSL中get/post等HTTP方法元素不再支持uri属性,改用path属性定义子路径。

修复步骤

1. 更新Camel Schema版本

将xsi:schemaLocation中的Camel Spring Schema版本从3.18.0替换为3.19.0:

http://camel.apache.org/schema/spring 
https://camel.apache.org/schema/spring/camel-spring-3.19.0.xsd

2. 替换HTTP方法元素的uri属性为path

将所有<get uri="/xxx">、<post uri="/xxx">中的uri替换为path,示例如下:

  • 原代码:<get uri="/hello"> → 修改后:<get path="/hello">
  • 原代码:<get uri="/bye" consumes="application/json"> → 修改后:<get path="/bye" consumes="application/json">
  • 原代码:<post uri="/bye"> → 修改后:<post path="/bye">

修改后的完整配置

<?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.19.0.xsd
       ">
       

    <camelContext
        xmlns="http://camel.apache.org/schema/spring">
        <rest path="/say">
            <get path="/hello">
                <to uri="direct:hello" />
            </get>
            <get path="/bye" consumes="application/json">
                <to uri="direct:bye" />
            </get>
            <post path="/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>

内容的提问来源于stack exchange,提问作者Balan Gurumurthi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 12:45:17