gpt4 book ai didi

java - Hibernate异常:could not parse

转载 作者:行者123 更新时间:2023-12-01 13:59:15 26 4
gpt4 key购买 nike

我遇到问题,无法解析配置 hibernate.cfg.xml

<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521/XE</property>
<property name="connection.username">system</property>
<property name="connection.password">system</property>
<property name="dialect">org.hibernate.OracleDialect</property>
<property name="show_sql">true</property>
<mapping calss="com.jlcindia.hibernate/Customer"/>
</session-factory>
</hibernate-configuration>

这里是异常(exception)...

Exception in thread "main" java.lang.ExceptionInInitializerError
at com.jlcindia.hibernate.AHLab2Client.main(AHLab2Client.java:15)
Caused by: org.hibernate.HibernateException: problem parsing
configurationhibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1291)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1230)
at com.jlcindia.hibernate.AHibernateUtil.<clinit>(AHibernateUtil.java:15)
... 1 more
Caused by: org.hibernate.MappingException: invalid configuration
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1287)
... 3 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 25; Document
is invalid: no grammar found.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
atorg.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.
scanRootElementHook(Unknown Source) at org.apache.xerces.impl.
XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:334)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1286)
... 3 more

我检查了我的数据库和所有标签,但我也无法解决它。请帮助我。

最佳答案

该行有 2 个错误

<mapping calss="com.jlcindia.hibernate/Customer"/>
  1. class 被错误地拼写为 calss

  2. com.jlcindia.hibernate/Customer 应该是 com.jlcindia.hibernate.Customer - 我假设这是实体类。

纠正两个错误后,该行应该是这样的

<mapping class="com.jlcindia.hibernate.Customer" />

旁注:一个好的 IDE 会在 xml 文件中突出显示错误(并指出错误的确切位置)。我建议您使用一个(如果您没有使用任何一个)。

关于java - Hibernate异常:could not parse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19431245/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com