Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Spring Integration have several XML schemas, and which one should I use?

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:

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.

from: http://static.springsource.org/spring-integration/reference/htmlsingle/#2.1-schema-updated

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.

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?

like image 660
sleske Avatar asked Jun 21 '12 12:06

sleske


1 Answers

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.

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.

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.xsd http\://www.springframework.org/schema/integration/spring-integration-2.0.xsd=org/springframework/integration/config/xml/spring-integration-2.0.xsd http\://www.springframework.org/schema/integration/spring-integration-2.1.xsd=org/springframework/integration/config/xml/spring-integration-2.1.xsd http\://www.springframework.org/schema/integration/spring-integration.xsd=org/springframework/integration/config/xml/spring-integration-2.1.xsd

like image 54
Gary Russell Avatar answered Nov 14 '22 00:11

Gary Russell