以下是Tomcat运行是所出现的错误,一开始还以为是Struts的问题,因为在第一行错误的时候说是对象初始化错误,所以一直没有往下看!!!最后感觉快要放弃的时候看了一下下面的错误!!!没有想到是hibernate.cfg.xml的错误!!以后记下了!!!
-
Caused by: org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
-
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1513)
-
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:990)
-
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:69)
-
at org.hibernate.cfg.Configuration.configure(Configuration.java:1447)
-
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:972)
-
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:69)
-
at org.hibernate.cfg.Configuration.configure(Configuration.java:1433)
-
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:966)
-
at com.barneyx.mt.permission.dao.UserDao.(UserDao.java:15)
-
... 93 more
解决方法:dtd不能解析,只要更换一下dtd的URL地址即可解决问题!!!
错误的Dtd地址:
正确的Dtd地址:
下面是完整的hibernate.cfg.xml的文件内容:
-
<?xml version="1.0" encoding="UTF-8"?>
-
<!--
-
此处为错误的URI地址,我已经注释起来了!
-
<!DOCTYPE hibernate-configuration PUBLIC
-
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
-
"">
-
-->
-
<!DOCTYPE hibernate-configuration PUBLIC
-
"-//Hibernate/Hibernate Configuration DTD//EN"
-
"">
-
<hibernate-configuration>
-
<session-factory>
-
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
-
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
-
<property name="hibernate.connection.username">root</property>
-
<property name="hibernate.connection.password">root</property>
-
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
-
-
<property name="show_sql">true</property>
-
<property name="current_session_context_class">thread</property>
-
-
</session-factory>
-
</hibernate-configuration>
阅读(925) | 评论(0) | 转发(0) |