弹簧配置错误 [英] Spring configuration error

查看:100
本文介绍了弹簧配置错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的spring-context文件如下所示。

 < beans xmlns =http://www.springframework。 org / schema / beans
xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance
xmlns:aop =http://www.springframework.org/ schema / aop
xmlns:jee =http://www.springframework.org/schema/jee
xmlns:jms =http://www.springframework.org/schema/jms
xmlns:lang =http://www.springframework.org/schema/lang
xmlns:tx =http://www.springframework.org/schema/tx
xmlns:util =http://www.springframework.org/schema/util
xsi:schemaLocation =http://www.springframework.org/schema/beans http://www.springframework.org /schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/jms http ://www.sp ringframework.org/schema/jms/spring-jms.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema / util http://www.springframework.org/schema/util/spring-util.xsd\">

< bean id =cfaBeanFactoryclass =org.springframework.context.support.ClassPathXmlApplicationContext>
< constructor-arg value =classpath:cfa-spring-core.xml/>
< / bean>
< / beans>

当我尝试运行我的应用程序时,出现以下错误:

 原因:org.springframework.beans.factory.access.BootstrapException:无法初始化组定义。组资源名称[classpath *:cfa-spring-context.xml],工厂密钥[cfaBeanFactory];嵌套异常是org.springframework.beans.factory.BeanDefinitionStoreException:来自URL [文件:/ C:/.../ cfa-spring-context.xml]的XML文档中的第16行无效;嵌套异常是org.xml.sax.SAXParseException:文档根元素beans,必须匹配DOCTYPE根null。 
at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:389)
... 56 more
引起:org.springframework.beans.factory.BeanDefinitionStoreException :来自URL [file:/ C:/.../ cfa-spring-context.xml]的XML文档中的第16行无效;嵌套异常是org.xml.sax.SAXParseException:文档根元素beans,必须匹配DOCTYPE根null。
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:169)
... 59 more
引起:org.xml.sax.SAXParseException:Document根元素beans,必须匹配DOCTYPE根null。
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)



有人能告诉我我做错了什么吗? 原来,这是因为我在Spring 1.x中使用Hibernate 3,这意味着DTD是错误的。更新了项目中的Spring JAR文件,解决了问题。


My spring-context file is shown below.

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:jms="http://www.springframework.org/schema/jms"
    xmlns:lang="http://www.springframework.org/schema/lang"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
        http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

    <bean id="cfaBeanFactory" class="org.springframework.context.support.ClassPathXmlApplicationContext">
        <constructor-arg value="classpath:cfa-spring-core.xml" />
    </bean>
</beans>

When I try to run my application, I get the following error:

Caused by: org.springframework.beans.factory.access.BootstrapException: Unable to initialize group definition. Group resource name [classpath*:cfa-spring-context.xml], factory key [cfaBeanFactory]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Line 16 in XML document from URL [file:/C:/.../cfa-spring-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
    at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:389)
    ... 56 more
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Line 16 in XML document from URL [file:/C:/.../cfa-spring-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:169)
    ... 59 more
Caused by: org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)

Can someone tell me what I'm doing wrong?

解决方案

Turns out this is because I'm using Hibernate 3 with Spring 1.x which means the DTDs are wrong. Updated the Spring JAR file in the project and that fixed the problem.

这篇关于弹簧配置错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆