此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Integration 6.3.1Spring中文文档

此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Integration 6.3.1Spring中文文档

您可以使用直接映射到企业集成的术语和概念的 XML 元素来配置 Spring Integration 组件。 在许多情况下,元素名称与《企业集成模式》一书中的元素名称相匹配。Spring中文文档

要在 Spring 配置文件中启用 Spring Integration 的核心命名空间支持,请在顶级“beans”元素中添加以下命名空间引用和模式映射:Spring中文文档

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:int="http://www.springframework.org/schema/integration"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           https://www.springframework.org/schema/beans/spring-beans.xsd
           http://www.springframework.org/schema/integration
           https://www.springframework.org/schema/integration/spring-integration.xsd">

(我们强调了 Spring Integration 特有的行。Spring中文文档

您可以在“xmlns:”之后选择任何名称。 为了清楚起见,我们使用(Integration的缩写),但您可能更喜欢另一个缩写。 另一方面,如果使用 XML 编辑器或 IDE 支持,则自动完成的可用性可能会说服您保留较长的名称以保持清晰。 或者,您可以创建使用 Spring Integration 架构作为主命名空间的配置文件,如以下示例所示:intSpring中文文档

<beans:beans xmlns="http://www.springframework.org/schema/integration"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:beans="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           https://www.springframework.org/schema/beans/spring-beans.xsd
           http://www.springframework.org/schema/integration
           https://www.springframework.org/schema/integration/spring-integration.xsd">

(我们强调了 Spring Integration 特有的行。Spring中文文档

使用此替代方法时,Spring Integration 元素不需要前缀。 另一方面,如果在同一配置文件中定义一个通用的 Spring bean,则 bean 元素需要前缀 ()。 由于模块化配置文件本身(基于职责或架构层)通常是一个好主意,因此您可能会发现在以集成为中心的配置文件中使用后一种方法是合适的,因为在这些文件中很少需要通用 bean。 在本文档中,我们假设集成命名空间是主要命名空间。<beans:bean …​/>Spring中文文档

Spring Integration 提供了许多其他命名空间。 事实上,提供命名空间支持的每个适配器类型(JMS、文件等)都在单独的模式中定义其元素。 要使用这些元素,请添加必要的命名空间,并添加一个条目和相应的映射。 例如,以下根元素显示了其中几个命名空间声明:xmlnsschemaLocationSpring中文文档

<?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:int="http://www.springframework.org/schema/integration"
  xmlns:int-file="http://www.springframework.org/schema/integration/file"
  xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
  xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
  xmlns:int-ws="http://www.springframework.org/schema/integration/ws"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
    https://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/integration
    https://www.springframework.org/schema/integration/spring-integration.xsd
    http://www.springframework.org/schema/integration/file
    https://www.springframework.org/schema/integration/file/spring-integration-file.xsd
    http://www.springframework.org/schema/integration/jms
    https://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
    http://www.springframework.org/schema/integration/mail
    https://www.springframework.org/schema/integration/mail/spring-integration-mail.xsd
    http://www.springframework.org/schema/integration/ws
    https://www.springframework.org/schema/integration/ws/spring-integration-ws.xsd">
 ...
</beans>

本参考手册在其相应章节中提供了各种要素的具体示例。 在这里,要识别的主要内容是每个命名空间 URI 和架构位置的命名一致性。Spring中文文档