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

如何解决Apache Camel升级后camel-spring.xsd文件未找到问题?

问题解决:Camel 4.7 + Spring Boot 3.3.3 启动时XML Schema加载失败

核心原因

  1. Spring Boot 3(基于Spring 6)默认禁用HTTP协议加载外部XML Schema,原配置中的HTTP地址会被安全拦截
  2. Camel 4.x的Spring Schema地址已更新,且需要与依赖版本严格匹配

解决方案

1. 替换Schema地址为HTTPS并指定版本

修改camel-context.xml中的xsi:schemaLocation配置,将Camel的Schema地址替换为对应版本的HTTPS地址:

<?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: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 https://camel.apache.org/schema/spring/camel-spring-4.7.xsd">
    <!-- 业务逻辑代码 -->
</beans>

注意:必须保证Schema版本与你使用的Camel版本(4.7)完全一致

2. 对齐所有Camel依赖版本

检查项目构建文件(pom.xml或build.gradle),确保所有Camel相关依赖的版本统一为4.7.0,避免版本冲突:

<!-- Spring Boot 父依赖 -->
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.3.3</version>
    <relativePath/>
</parent>

<!-- Camel Spring Boot Starter -->
<dependency>
    <groupId>org.apache.camel.springboot</groupId>
    <artifactId>camel-spring-boot-starter</artifactId>
    <version>4.7.0</version>
</dependency>

<!-- Camel Mail Starter -->
<dependency>
    <groupId>org.apache.camel.springboot</groupId>
    <artifactId>camel-mail-starter</artifactId>
    <version>4.7.0</version>
</dependency>

3. 可选:从Classpath加载Schema(无需网络)

如果不想依赖外部网络,可直接从本地依赖的JAR包中加载Schema,修改地址为Classpath路径:

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                    http://camel.apache.org/schema/spring classpath:org/apache/camel/spring/schema/camel-spring-4.7.xsd">

补充说明

  • Spring 6的安全策略默认拒绝HTTP外部资源加载,因此必须改用HTTPS或本地资源
  • Camel 4.x对Spring集成的Schema结构做了调整,指定对应版本的Schema可避免兼容性异常

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 02:17:04