我正在尝试运行一个示例Hibernate程序,该程序将一个值插入到数据库中,但我得到了下面的错误,其中我已经在我的构建路径中包括slf4j JAR,请帮助我解决这个问题。
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2246)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2158)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2137)
at org.test1.HibernateTest.main(HibernateTest.java:18)
Caused by: org.dom4j.DocumentException: Error on line 2 of document : The document type declaration for root element type "hibernate-configuration" must end with '>'. Nested exception: The document type declaration for root element type "hibernate-configuration" must end with '>'.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2238)
... 3 more发布于 2013-06-26 03:46:26
错误非常明显,在文件hibernate.cfg.xml中的某个位置,您错误地关闭了一个XML标记,可能缺少一个>字符(可能在元素hibernate-configuration中?)。用一个好的文本编辑器检查文件,它会帮助你找到问题所在。
发布于 2013-06-26 13:37:41
我想你忘了正确地关闭'>‘--这只是一个编译错误
发布于 2014-03-09 01:02:21
您可能没有在hibernate.cfg.xml中提到文档类型
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration>
使用上面的语法,它应该可以工作。
https://stackoverflow.com/questions/17306099
复制相似问题