[英]What is the proper way to specify a xsd within a spring bean.xml
The beginning of my working bean.xml file looks like the following:我的工作 bean.xml 文件的开头如下所示:
<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我碰巧把下面的网址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.我下载了 spring-beans-4.2.xsd 和 spring-beans.xsd 并对它们进行了比较。 They seem to be identical.它们似乎完全相同。 Therefore, should I specify spring-beans-4.2.xsd or spring-beans.xsd.因此,我应该指定 spring-beans-4.2.xsd 还是 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. 1. 如果我使用 spring-beans.xsd 那么我似乎总是会得到最新版本。 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. 2. 参考 #1 这可能很糟糕,因为 .xsd 中的某些内容可能会发生变化并破坏我的验证。
My feeling is to lock in the .xsd with spring-beans-4.2.xsd and change the bean.xml file when I am ready.我的感觉是用 spring-beans-4.2.xsd 锁定 .xsd 并在我准备好时更改 bean.xml 文件。 Thoughts on this observation would be greatly appreciated.对这一观察的想法将不胜感激。
我宁愿指定特定版本,因为有时存在依赖项冲突问题,因此http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
应该可以。
The advice for some time now has been to use the versionless schema, especially now Spring 5 has been released, which doesn't have a versioned schema (See [SPR-13499] )一段时间以来的建议是使用无版本模式,尤其是现在 Spring 5 已经发布,它没有版本模式(参见[SPR-13499] )
A more complete answer can be found at Spring configuration XML schema: with or without version?可以在Spring configuration XML schema: with or without version? 中找到更完整的答案。
THis question should have been closed as a duplicate of that question, but it's too late to do that now.这个问题应该作为该问题的副本而关闭,但现在这样做已经太晚了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.