搜索

1.3. Spring XML 文件中的路由器架构

download PDF

Namespace

路由器模式都包括在以下 XML 模式命名空间中:

http://camel.apache.org/schema/spring

指定模式位置

路由器模式的位置通常指定为 http://camel.apache.org/schema/spring/camel-spring.xsd,它引用 Apache 网站中的模式的最新版本。例如,Apache Camel Spring 文件的 root Bean 元素通常配置,如 例 1.2 “指定路由器架构位置” 所示。

例 1.2. 指定路由器架构位置

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:camel="http://camel.apache.org/schema/spring"
       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-2.0.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
    <!-- Define your routing rules here -->
  </camelContext>
</beans>

Runtime 模式位置

在运行时,Apache Camel 不会从 Spring 文件中指定的模式位置下载路由器模式。相反,Apache Camel 会自动从 camel-spring JAR 文件的根目录中获取 schema 的副本。这样可确保用于解析 Spring 文件的模式版本始终与当前的运行时版本匹配。这一点很重要,因为发布在 Apache Web 站点上的架构的最新版本可能与您当前使用的运行时版本不匹配。

使用 XML 编辑器

通常,建议您使用功能齐全的 XML 编辑器编辑 Spring 文件。XML 编辑器的自动完成功能可以更轻松地编写 XML,该 XML 符合路由器模式,如果 XML 的格式不正确,编辑器可以立即警告您。

XML 编辑器 通常 依赖从 xsi:schemaLocation 属性中指定的位置下载模式。为了确保您使用正确的模式版本 whilst 编辑,最好选择 camel-spring.xsd 文件的特定版本。例如,要为 Apache Camel 的 2.3 版本编辑 Spring 文件,您可以修改 beans 元素,如下所示:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:camel="http://camel.apache.org/schema/spring"
       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-2.0.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring-2.3.0.xsd">
...

完成编辑后,重新更改为默认的 camel-spring.xsd。要查看当前可用的模式版本,请导航到网页 http://camel.apache.org/schema/spring

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.