首页 > 解决方案 > root-context.xml] 无效;嵌套异常是 org.xml.sax.SAXParseException;cvc-elt.1:找不到元素“beans”的声明

问题描述

我在多个问题中看到了同样的错误,并尝试了每个解决方案。似乎没有任何效果。我修剪了错误以便更容易粘贴错误在第 7 行的引用。这是我的xml代码。TIA EDIT 我添加了调用 root-context.xml 的代码

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee web-app_2_5.xsd" 
version="2.5">
<display-name>Subject</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
</web-app>


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

<beans:import resource="security-context.xml" /> 
<beans:bean id="subjectProps" 
    class="org.springframework.beans.factory.config.PropertiesFactoryBean"> 
    <beans:property name="locations">
        <beans:list> 
            <beans:value>WEB-INF/spring/subject.properties</beans:value> 
            <beans:value>WEB-INF/spring/subject_sql.properties</beans:value> 
        </beans:list> 
    </beans:property> 
</beans:bean>

<beans:bean id="subjectUtilProperites" 
 class="main.java.mil.serena.subject.common.SubjectProperties"> 
    <beans:property name="properties" ref="subjectProps"/> 
</beans:bean> 
<beans:bean id="publicationUtilProperties" 
  class="main.java.mil.serena.web.common.properties.SubPubProperties"> 
    <beans:property name="properties" ref="subjectProps"/> 
</beans:bean>
</beans>

标签: javaxmlxsdxsd-validationxml-validation

解决方案


改变

    xsi:schemLocation="

    xsi:schemaLocation="
             ^

推荐阅读