回答を探していたこのフォーラムを徹底的に検索したところ、私の場合と同様の単一のケースは見つかりませんでした。WebProjectのクラスパスにMETA-INF/persistence.xmlファイルが見つかりませんでした
毎回、Mavenを使用して、私のサーバーを展開ファイラWARを生成した後、私は、サーバーのコンソールに次の警告が出DAOを作成する必要があるAPIにGETリクエストを送信します。
見つかりませんでした。任意のMETA-INF /クラスパス
と、次の例外でのpersistence.xmlファイル:mim_ajudaという名前のEntityManagerのための
ません永続プロバイダコードのこのセクションに
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="mim_ajuda" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/mim_ajuda" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="[email protected]" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.hbm2ddl.auto" value="validate" />
<!-- Configuring Connection Pool -->
<property name="hibernate.c3p0.min_size" value="5" />
<property name="hibernate.c3p0.max_size" value="20" />
<property name="hibernate.c3p0.timeout" value="500" />
<property name="hibernate.c3p0.max_statements" value="50" />
<property name="hibernate.c3p0.idle_test_period" value="2000" />
</properties>
</persistence-unit>
</persistence>'
:私はさらにこれで行くことができる前に、私はすでにpersistence.xmlのをどこに置くかを検索し、THISページに応じてきた
private EntityManager getEntityManager(){ EntityManagerFactory factory = Persistence .createEntityManagerFactory("mim_ajuda"); if(entityManager == null){ entityManager = factory.createEntityManager(); }
return entityManager; }
いくつかの他のユーザの場合、XMLはWARファイル(私のものです)内の "WEB-INF/classes/META-INF/persistence.xml"ディレクトリになければなりません。
はは、要約すると :
- 自動テスト作業をうまく実行オフラインとのEntityManager
- 私はこのエラーを取得するWebサービスAPIを呼び出すときにのみ
- persinstence.xmlファイルには、次のを使用して他の質問に示されているパス。