hibernate - Spring 配置错误

标签 hibernate spring

我的 Spring 上下文文件如下所示。

<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>

当我尝试运行我的应用程序时,出现以下错误:
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)

有人能告诉我我做错了什么吗?

最佳答案

原来这是因为我在 Spring 1.x 中使用了 Hibernate 3,这意味着 DTD 是错误的。更新了项目中的 Spring JAR 文件并解决了问题。

关于hibernate - Spring 配置错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/266601/

相关文章:

hibernate - 级联仅删除grails中的事务表

java - struts 2中使用session访问实体bean数据的标准流程是什么?

eclipse - tomcat找不到maven依赖

java - Hibernate异常: Unable to access lob stream

hibernate - JPA Hibernate 合并执行插入而不是更新

java - 哪个对性能更好 - 对数据库进行批量调用或使用循环进行计算的单个调用?

java - 如何始终在 spring 应用程序中启用我的 Hibernate 过滤器?

java - 文件 : spring-security. xml 没有嵌入样式表指令

spring - 使用 JpaRepository 的动态搜索查询

Spring @Transactional 包装 2 种方法