【发布时间】:2016-10-03 11:01:23
【问题描述】:
在我们基于 Spring 的应用程序中,我们使用来自位于 http://www.springframework.org/schema/security/spring-security.xsd 的命名空间 http://www.springframework.org/schema/security 的元素来补充应用程序上下文文件:
<beans ...
xmlns:security="http://www.springframework.org/schema/security"
...
xsi:schemaLocation="...
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd"> ... </beans>
但是,最近我们收到了这个错误信息
Multiple annotations found at this line:
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'security:global-method-security'.
- schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/security/spring-security.xsd', because 1) could not
find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
在我们的项目初始设置后或清除 Eclipse 的网络缓存后,在 Eclipse 的 XML 编辑器中打开应用程序上下文文件时。
对 archive.org 的进一步研究表明,当当前版本 (spring-security-4.1.xsd) 于 2016 年 3 月 8 日左右发布时,无版本 XSD 已被删除。
有没有人知道这是否是偶然发生的,或者是否有更深层的原因导致移除?对于其他命名空间,springframework.org/schema/ 上仍有可用的无版本 XSD,即 spring-security-oauth.xsd 和 spring-beans.xsd。 (由于我的声誉等级低,我无法发布指向他们的明确链接。)
作为一种解决方法,我们现在引用一个版本化的 XSD。然而,到目前为止,我的印象是 Spring 鼓励使用无版本 XSD,例如 current Spring security reference documentation 或 this SO post 中所建议的。
【问题讨论】:
-
因为使用架构而不指明您想要的架构的哪个版本不是一个好主意?
-
@vzamanillo:感谢您提供实际链接。
-
@Raedwald:不确定我是否应该同意这种情况,因为 Spring 似乎鼓励使用无版本 XSD。
标签: java xml eclipse spring spring-security