root-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; cvc-elt.1: Cannot find the declaration of element 'beans'

huangapple go评论83阅读模式
英文:

root-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; cvc-elt.1: Cannot find the declaration of element 'beans'

问题

我在多个问题中看到了相同的错误,并尝试了每个解决方案。似乎没有任何解决办法。我已经修剪了错误以便于更容易地粘贴,错误位于第7行的引号处。以下是我的 XML 代码。

TIA
编辑:我添加了调用 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:schemaLocation="
        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>
英文:

I have seen this same error in multiple questions and tried each solution. Nothing seems to work. I trimmed the error for easier pasting the error is on line 7 at the quote. Here is my xml code.
TIA
EDIT I added the code that calls the root-context.xml

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


&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt; 
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot; 
    xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; 
    xmlns:util=&quot;http://www.springframework.org/schema/util&quot; 
    xmlns:beans=&quot;http://www.springframework.org/schema/beans&quot; 
    xsi:schemLocation=&quot;
    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"> 	
 
&lt;beans:import resource=&quot;security-context.xml&quot; /&gt; 
&lt;beans:bean id=&quot;subjectProps&quot; 
    class=&quot;org.springframework.beans.factory.config.PropertiesFactoryBean&quot;&gt; 
    &lt;beans:property name=&quot;locations&quot;&gt;
	    &lt;beans:list&gt; 
            &lt;beans:value&gt;WEB-INF/spring/subject.properties&lt;/beans:value&gt; 
		    &lt;beans:value&gt;WEB-INF/spring/subject_sql.properties&lt;/beans:value&gt; 
		&lt;/beans:list&gt; 
	&lt;/beans:property&gt; 
&lt;/beans:bean&gt;

&lt;beans:bean id=&quot;subjectUtilProperites&quot; 
 class=&quot;main.java.mil.serena.subject.common.SubjectProperties&quot;&gt; 
	&lt;beans:property name=&quot;properties&quot; ref=&quot;subjectProps&quot;/&gt; 
&lt;/beans:bean&gt; 
&lt;beans:bean id=&quot;publicationUtilProperties&quot; 
  class=&quot;main.java.mil.serena.web.common.properties.SubPubProperties&quot;&gt; 
	&lt;beans:property name=&quot;properties&quot; ref=&quot;subjectProps&quot;/&gt; 
&lt;/beans:bean&gt;
&lt;/beans&gt;

答案1

得分: 1

将以下内容翻译为中文:

    xsi:schemLocation=&quot;

替换为

    xsi:schemaLocation=&quot;
             ^
英文:

Change

    xsi:schemLocation=&quot;

to

    xsi:schemaLocation=&quot;
             ^

huangapple
  • 本文由 发表于 2020年8月20日 04:47:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/63494774.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定