为什么 Spring Integration 有多个 XML 模式,我应该使用哪一个? [英] Why does Spring Integration have several XML schemas, and which one should I use?
问题描述
要在 Spring XML 配置文件中使用 Spring Integration,我需要声明 si
命名空间,并提供 XML Schema 的模式位置:
To use Spring Integration in a Spring XML configuration file, I need to declare the si
namespace, and provide the schema location of the XML Schema:
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
但是,根据文档,有两种模式可供选择:
However, according to the docs, there are two schemas to choose from:
从现在开始,用户必须始终声明最新的 XML 模式(当前版本 2.1).或者,他们可以使用无版本架构.通常,最好的选择是使用无版本命名空间,因为这些将自动使用最新可用的 Spring 版本整合.
From now on, users must always declare the latest XML schema (currently version 2.1). Alternatively, they can use the version-less schema. Generally, the best option is to use version-less namespaces, as these will automatically use the latest available version of Spring Integration.
来自:http://static.springsource.org/spring-integration/reference/htmlsingle/#2.1-schema-updated
为什么同时存在 spring-integration.xsd
和 spring-integration-2.1.xsd
?两个我都查了,后者几乎是前者的三倍大.
Why is there both spring-integration.xsd
and spring-integration-2.1.xsd
? I checked both, and the latter is almost three times as large as the former.
那么为什么文档说使用无版本架构更好呢?使用其中一个或另一个的后果是什么?还是只是spring-integration.xsd
和spring-integration-2.1.xsd
不同的bug?
So why do the docs say that it's better to use the version-less schema? What are the consequences of using either one or the other? Or is it just a bug that spring-integration.xsd
and spring-integration-2.1.xsd
are different?
推荐答案
您不应该查看托管在 Internet 上的模式;模式分布在罐子中;META-INF下还有一个映射文件.
You shouldn't look at the schemas hosted on the internet; the schemas are distributed in the jars; there is also a mapping file under META-INF.
正如您在下面看到的,我们总是将无版本模式映射到当前模式;因此我们建议始终在应用程序配置中使用无版本模式,否则每次升级时都必须更改文件;例如,2.2 不会使用 2.1 架构运行,但是,如果您在架构上不使用任何版本,则框架将负责使用正确的架构.
As you can see, below, we always map the version-less schema to the current schema; so we recommend always using the version-less schema in your application configs, otherwise you will have to change your files whenever you upgrade; for example 2.2 won't run with a 2.1 schema but, if you use no version on the schema, the framework will take care of using the right one.
互联网上的无版本架构是旧的 1.0 架构;我们需要弄清楚如何才能改变这一点,但这并不简单,出于各种原因,
The version-less schema on the internet is an old 1.0 schema; we need to figure out how we can change that, but it's not simple, for various reasons,
<代码>http://www.springframework.org/schema/integration/spring-integration-1.0.xsd=org/springframework/integration/config/xml/spring-integration-1.0.xsdhttp://www.springframework.org/schema/integration/spring-integration-2.0.xsd=org/springframework/integration/config/xml/spring-integration-2.0.xsdhttp://www.springframework.org/schema/integration/spring-integration-2.1.xsd=org/springframework/integration/config/xml/spring-integration-2.1.xsdhttp://www.springframework.org/schema/integration/spring-integration.xsd=org/springframework/integration/config/xml/spring-integration-2.1.xsd
这篇关于为什么 Spring Integration 有多个 XML 模式,我应该使用哪一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!