简体   繁体   中英

Hibernate: Exception in thread “main” org.hibernate.MappingException: invalid configuration

I'm having troubles with my hibernate.cfg.xml-file with which I try to export the attributes of an object to an Apache Derby table.

<?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>

The Exception message is following:

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

What could here be the problem?

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

should be replaced with

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

simply, a wrong formatted XML

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM