1

The beginning of my working bean.xml file looks like the following:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation=
  "http://www.springframework.org/schema/beans 
   http://www.springframework.org/schema/beans/spring-beans-4.2.xsd

   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-4.2.xsd">

I happened to put the following URL http://www.springframework.org/schema/beans

which returned a list that looks like the following

spring-beans-2.0.xsd
spring-beans-2.5.xsd
spring-beans-3.0.xsd
spring-beans-3.1.xsd
spring-beans-4.0.xsd
spring-beans-4.1.xsd
spring-beans-4.2.xsd
spring-beans.xsd

I downloaded spring-beans-4.2.xsd and spring-beans.xsd and did a diff on them. They seem to be identical. Therefore, should I specify spring-beans-4.2.xsd or spring-beans.xsd. Two concerns come to mind. 1. If I use spring-beans.xsd then it would seem that I would always get the latest version. This could be good if they are always backward compatible. 2. Referring to #1 this could be bad because something may change in the .xsd and break my validation.

My feeling is to lock in the .xsd with spring-beans-4.2.xsd and change the bean.xml file when I am ready. Thoughts on this observation would be greatly appreciated.

ArtIsConfused
  • 17
  • 1
  • 7

2 Answers2

0

I would rather specify particular version, as sometimes there are problem with dependencies conflict, so http://www.springframework.org/schema/beans/spring-beans-4.2.xsd should be fine.

m.aibin
  • 3,528
  • 4
  • 28
  • 47
0

The advice for some time now has been to use the spring-beans.xsd versionless schema, especially now Spring 5 has been released, which only includes versioned schemas for earlier versions (See [SPR-13499]).

A more complete answer can be found at Spring configuration XML schema: with or without version? but a summary is that the only time you need to use a versioned schema is if you want to upgrade spring to a version with a breaking change to an element you rely on (which is very rare), and you don't want to update your beans.

This question should have been closed as a duplicate of the referenced question, but it's too late to do that now.

Mark Booth
  • 7,605
  • 2
  • 68
  • 92