gpt4 book ai didi

java - Hibernate:线程 "main"org.hibernate.MappingException 中出现异常:无效配置

转载 作者:行者123 更新时间:2023-12-01 11:46:18 25 4
gpt4 key购买 nike

我在尝试使用 hibernate.cfg.xml 文件将对象的属性导出到 Apache Derby 表时遇到问题。

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">


<hibernate-configuration>

<session-factory>

<!-- Database connection settings -->
<property name="connection.driver_class">org.apache.derby.jdbc.EmbeddedDriver</property>
<property name="connection.url">jdbc:derby:C:\Users\laudatio\Documents\JavaLibs\HibernateDB;create=true</property>
<property name="connection.username">hibernate</property>
<property name="connection.password">hibernate</property> />

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">2</property>

<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.DerbyDialect</property>

<!-- Enable Hibernate's current session context -->
<property name="current_session_context_class">thread</property>


<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>

<!-- Drop and re-create the database schema on startup -->
<!-- <property name="hbm2ddl.auto">create</property>
<mapping resource="org/hibernate/tutorial/domain/Event.hbm.xml" />
<mapping resource="org/hibernate/tutorial/domain/Person.hbm.xml" /> -->

</session-factory>

</hibernate-configuration>

异常消息如下:

18:01:01,080 DEBUG DTDEntityResolver:69 - Trying to resolve system-id [http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd]
18:01:01,081 DEBUG DTDEntityResolver:71 - Recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
18:01:01,081 DEBUG DTDEntityResolver:108 - Located [http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd] in classpath
Exception in thread "main" org.hibernate.MappingException: invalid configuration

这可能是什么问题?

最佳答案

<property name="connection.password">hibernate</property> />

应替换为

<property name="connection.password">hibernate</property>

简单地说,XML 格式错误

关于java - Hibernate:线程 "main"org.hibernate.MappingException 中出现异常:无效配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29105304/

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