Рассмотрим эту структуру:persistence.xml зависимость в тесте Maven
/project
/module-1
/src/test/resources/META-INF/persistence.xml
/module-2
В модуле-1 тест-банке создается. модуль-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>
Этот тест баночка является зависимость в модуле-2/pom.xml:
<dependency>
<groupId>com.domain.test</groupId>
<artifactId>module-1</artifactId>
<scope>test</scope>
<type>jar</type>
</dependency>
Проблема заключается в том, что в тестах модуля-2, persitence единиц (PU), определенный в /src/test/resources/META-INF/persistence.xml, не может быть найден. PU создаются программно:
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory(persistenceUnit);
EntityManager entityManager = entityManagerFactory.createEntityManager();
Как я могу заставить его работать? Благодарю.