Netbeans で Persistence Unit を作成した後、Persistence.xml ファイルを削除しました。プロジェクトを実行するたびに、「Hi__Score_OldPU という名前の EntityManager の永続化プロバイダーがありません」のような大量のエラーが表示されます。Persistence Unit を完全に削除するにはどうすればよいですか?
1590 次
1 に答える
0
このエラーは、persistence.xml が間違った場所 (プロジェクト --> WebContent --> META-INF -->persistence.xml) にある場合に発生します。
ここにあるはずです(src-->META-INF-->persistence.xml)
そのフォルダーが存在しない場合は、src にフォルダー "META-INF" を作成し、persistence.xml をそのフォルダーに配置できます。
ここで私のpersistence.xmlは次のようになります。
`
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun. com/xml/ns/persistence/persistence_2_0.xsd ">
<persistence-unit name="livraria" transaction-type ="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>br.com.k19.modelo.Editora</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/K21_livraria_bd"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="root"/>
</properties>
</persistence-unit>
`
于 2013-11-04T17:00:19.157 に答える