見つかりませんでした。休止状態:ドキュメントが無効である:私は、次のコードを使用休止状態をインスタンス化するとき何の文法は
org.xml.sax.SAXParseException:ドキュメントがある
Configuration configuration = new Configuration(); configuration.configure(); serviceRegistry = new ServiceRegistryBuilder().applySettings( configuration.getProperties()).buildServiceRegistry(); sessionFactory = configuration.buildSessionFactory(serviceRegistry);
を私は次の例外を得ました無効:文法が見つかりません。 org.xml.sax.SAXParseException:ドキュメントルート要素 "hibernate-configuration"は、DOCTYPEルート "null"と一致する必要があります。 原因:org.hibernate.MappingException:無効なコンフィグレーション at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2014) at org.hibernate.cfg.Configuration.configure(Configuration.java:1931) at (HibernateUtil.java:23) ... 1もっと見る 原因:org.xml.sax.SAXParseException :ドキュメントが無効です:文法が見つかりません。
は、私は、Hibernate 4.1.6で以下のhibernate.cfg.xml
ファイルを使用します。
<?xml version='1.0' encoding='utf-8'?>
<hibernate-configuration
xmlns="http://www.hibernate.org/xsd/hibernate-configuration"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.apache.derby.jdbc.ClientDriver</property>
<property name="connection.url">jdbc:derby://localhost:1527/K:\db</property>
<property name="connection.username"></property>
<property name="connection.password"></property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.DerbyDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<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">update</property>
</session-factory>
</hibernate-configuration>
私はこの例外を排除するために何ができますか?
'DOCTYPE'を追加するだけでは十分ではありません、' hibernate-configuration'要素からすべての属性を削除しなければなりませんでした。hibernateが 'XSD'を介して' DTD'を好むことを奇妙に見てください。 ouは、 '' DTD'' urlに古いsourceforge URLの代わりに '' http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd ''を使うように更新するかもしれません。 – Sydney