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

标签 java hibernate

我在尝试使用 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/

相关文章:

java - 带有子查询的 JPQL 以选择最大计数

java - 是否可以将 Http Session 对象从一个 VM 迁移到另一个 VM?

Java 基本日历打印

java - org.postgresql.util.PSQLException : ERROR : relation does NOT exist PreparedStatement.executeQuery()

java - 关闭 hibernate 日志控制台输出

java - Hibernate二级单向映射

java - 构造函数 Category(String, String) 不可见 - 使用 lombok 为某些字段创建构造函数?

java - 如何将信息存储在 float 中并使其可重复使用?

java - 应用程序的 map 在请求权限后首次运行时保持空白,但在关闭并重新打开后可以正常工作

mysql - Spring boot - Hibernate JPA 不创建 MySql DB 表