共通、サーバー、戦争などのさまざまなモジュールを使用して Maven プロジェクトを構築しようとしています。エンティティ Bean とその他の JPA のものを共通モジュールに保持しています。プロジェクトのフォルダ構成は以下の通りです:::
common
-->src
---->main
----->java
------>com
------->hello
-------->domain --------- Domain Classes
----->resources
------>META-INF --------- persistence.xml
---->test
----->java
------>com
------->hello
-------->test
--------->domain --------- Test Classes
----->resources
------>META-INF --------- persistence.xml
2 つの persistence.xml があります。1 つ目は src\main\resources\META-INF にあります。2 つ目は src\test\resources\META-INF にあります。テスト ケースを実行するために、後で 2 番目の persistence.xml をメモリ DB にポイントします。
テストクラスでは、以下のようにエンティティマネージャーを作成しようとしています:
EntityManager em = (EntityManager) Persistence.createEntityManagerFactory("Test-Persistence").createEntityManager();
テスト ケースが失敗し、次のような例外が発生します。
com.hello.test.domain.TestUser: No Persistence provider for EntityManager named Test-Persistence
誰でも私が間違っているところを提案してもらえますか?
よろしく
アミット・ナイア