SAXParseException,文档的根元素不是<xsd:schema>



这是我的spring-security.xml:的标题

<?xml version="1.0" encoding="UTF-8" ?>
<b:beans xmlns:b="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:sec="http://www.springframework.org/schema/security"
         xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
         xmlns:context="http://www.springframework.org/schema/context"  
         xmlns:mvc="http://www.springframework.org/schema/mvc"  
         xsi:schemaLocation="http://www.springframework.org/schema/security
          http://www.springframework.org/schema/security/spring-security-3.2.xsd
          http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
          http://www.springframework.org/schema/security/oauth2
          http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context-3.2.xsd
          http://www.springframework.org/schema/mvc
          http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd  ">

当启动服务器时,我会收到以下错误提示:

org.xml.ax.SAXParseException:schema_rereference.4:读取失败模式文档'http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd',因为1)找不到文档;2) 该文档不能阅读3) 文档的根元素不是<xsd:schema/>。

我对此的看法:

  1. 链接有效且文档存在

  2. 如果我把xsd放在本地类路径上,我可以读取它,甚至可以重现这个错误。所以这不是网络问题。

  3. 没错,该文件是由<xs:schema>而不是<xsd:schema>启动的。但消息来源看起来是合法的。

为什么我会出现这个错误,我该如何消除它?

更改所有模式位置以使用无版本URI,这些XSD嵌入在Spring JAR中。

因为您使用的是指向XSD的版本化链接,所以如果您的应用程序在类路径上找不到特定版本,它就会中断。

请参阅此SO答案以了解更多详细信息。

相关内容

最新更新