【问题标题】:XML schema error with JettyJetty 的 XML 架构错误
【发布时间】:2011-05-17 20:54:40
【问题描述】:

当我在码头运行时,我的 spring 配置有问题。我在tomcat中使用了完全相同的文件,没有任何问题。我得到的错误如下。

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 6 in XML document from ServletContext resource [/WEB-INF/web-application-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'SpringSource.org | '.
Caused by: org.xml.sax.SAXParseException: s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'SpringSource.org | '.

我的架构如下所示。

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.5.xsd">

我不知道有什么问题。用 2 种不同的配置对其进行了测试,都给出了这个错误。

【问题讨论】:

标签: java xml xsd spring-security jetty


【解决方案1】:

以下 URL 似乎无效,并重定向到 springsource.org

http://www.springframework.org/schema/security/spring-security-3.0.5.xsd

你可以试试那个吗?

http://www.springframework.org/schema/security/spring-security-3.0.4.xsd

【讨论】:

  • 啊 tnx。如此简单的解决方案。由于我之前遇到过此类错误,因此我预计无效模式位置会出现其他错误。仍然有同样的错误,但现在更详细了。
【解决方案2】:

我认为是弹簧安全部分搞砸了,请查看Spring 3.0 - Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security] 寻求解决方案。 (简短回顾一下,如果您使用的是 maven,您的类路径中缺少 Spring Security Config jar,请添加以下依赖项)

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-config</artifactId>
    <version>3.0.1.RELEASE</version>
</dependency>

【讨论】:

    【解决方案3】:

    显然,XML 属性中不能有换行符。

    xsi:schemaLocation属性值全部放在一行内。

    【讨论】:

    • 我认为这个答案是错误的,例如stackoverflow.com/a/449647/90033
    • @Konstantin:这不是 XML 标准的问题,而是当这个特定的解析器无法加载外部模式时发生的问题。
    • 我知道,但您的回答似乎暗示他不能在 xml 属性中添加换行符,这是不正确的
    猜你喜欢
    • 1970-01-01
    • 2012-12-08
    • 1970-01-01
    • 2013-03-31
    • 1970-01-01
    • 1970-01-01
    • 2016-04-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多