この構造を考えてみましょう。
/project
/module-1
/src/test/resources/META-INF/persistence.xml
/module-2
モジュール1では、テストjarが作成されます。module-1 / pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
このテストjarは、module-2/pom.xmlの依存関係です。
<dependency>
<groupId>com.domain.test</groupId>
<artifactId>module-1</artifactId>
<scope>test</scope>
<type>jar</type>
</dependency>
問題は、モジュール2のテストで、/src/test/resources/META-INF/persistence.xmlで定義されているpersitenceunits(PU)が見つからないことです。PUはプログラムで作成されます。
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory(persistenceUnit);
EntityManager entityManager = entityManagerFactory.createEntityManager();
どうすればそれを機能させることができますか?ありがとう。