Hibernate:Hibernate3.3和3.6的配置文件的头不一样

Hibernate3.3和3.6的配置文件的头不一样

1,Hibernate 3.6.0 的XML的头:

 

    <!-- hibernate.cfg.xml文件 -->

    <!DOCTYPE hibernate-configuration PUBLIC

       "-//Hibernate/HibernateConfiguration DTD 3.0//EN"

       "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

 

    <!-- hbm.xml文件 -->

    <!DOCTYPE hibernate-mapping PUBLIC

       "-//Hibernate/Hibernate Mapping DTD3.0//EN"

       "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

 

    <!-- hbm.xml文件中也可以使用这个 -->

    <!doctype hibernate-mapping public

        "-//hibernate/hibernate mappingdtd 3.0//en"

        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

 

 

2,Hibernate 3.3.1 的XML的头:

 

    <!-- hibernate.cfg.xml文件 -->

    <!DOCTYPE hibernate-configuration PUBLIC

          "-//Hibernate/HibernateConfiguration DTD 3.0//EN"

          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

   

    <!-- hbm.xml文件 -->

    <!DOCTYPE hibernate-mapping PUBLIC

        "-//Hibernate/Hibernate MappingDTD 3.0//EN"

       "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

 

 

 

 

 

头不能写错,否则会抛如下异常:

Caused by:org.hibernate.HibernateException: Could not parse configuration:file:/E:/workspace/ItcastOA/WebRoot/WEB-INF/classes/hibernate.cfg.xml

    atorg.hibernate.cfg.Configuration.doConfigure(Configuration.java:1528)

    at org.hibernate.cfg.Configuration.configure(Configuration.java:1477)

    atorg.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:601)

    atorg.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)

    atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)

    atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)

    ... 48 more

Causedby: org.dom4j.DocumentException: www.hibernate.org Nested exception:www.hibernate.org

    atorg.dom4j.io.SAXReader.read(SAXReader.java:484)

    atorg.hibernate.cfg.Configuration.doConfigure(Configuration.java:1518)

    ... 53 more

你可能感兴趣的:(Hibernate:Hibernate3.3和3.6的配置文件的头不一样)