小弟由于刚开始学习hibernate,出了以下问题,希望大家帮我解决一下,谢谢。这是我的:hibernate.cfg.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.3//EN "
"http://hibernate.sourceforge.net/hibernate-mapping-3.3.dtd"><hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/student/chengji</property>
<property name="connection.username">root</property>
<property name="connction.password">123</property><property name="connection.pool_size">1</property><property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="current_session_context_class">thread</property><property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<proterty name="show_sql">true</proterty>
<property name="hbm2ddl.auto">create</property>
<mapping resource="default package/user.hbm.xml"/>
</session-factory>
</hibernate-configuration>
错误是:
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1528)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1448)
at Test.main(Test.java:6)
Caused by: org.dom4j.DocumentException: http://hibernate.sourceforge.net/hibernate-mapping-3.3.dtd Nested exception: http://hibernate.sourceforge.net/hibernate-mapping-3.3.dtd
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1518)
... 3 more

解决方案 »

  1.   

    可能是xml标签下错了 Could not parse 
      

  2.   

    把 at Test.main(Test.java:6)  发上来看看 帮你解析解析
      

  3.   

    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    你的文件头是映射文件的。。
      

  4.   

    <?xml version='1.0' encoding='GB18030'?>
    <!DOCTYPE hibernate-configuration PUBLIC
              "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
              "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">文件头有问题。。改成这个看看
      

  5.   

    <!DOCTYPE hibernate-configuration PUBLIC
              "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
              "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
      

  6.   

    把头文件该成:
    <!DOCTYPE hibernate-configuration PUBLIC
              "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
              "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">在看hibernate.cfg.xml是不是在src下面