1

I am trying to have a seperate persistence.xml for my tests, but it is not working. I have already looked at this post :

JPA using alternative "persistence.xml"

The post states that I just need to have a persistence.xml file in my src/test/resources/META-INF directory. This persistence file contains my JPA configuration for the test phase (In my case just the in-memory database).

However when I run Maven-->Test ALWAYS picks up the main/src persistence.xml file.

Do I need to configure something extra in my POM? My POM feels pretty sparse :

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.glassfish.embedded.samples.ejbcontainer</groupId>
    <artifactId>ejbcontainer</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>ejbcontainer</name>
    <url>http://maven.apache.org</url>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.glassfish.main.extras</groupId>
            <artifactId>glassfish-embedded-all</artifactId>
            <version>3.1.2</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
</project>

Here's what it looks like in netbeans

enter image description here

Test phase always goes to the main persistence.xml :(

Community
  • 1
  • 1
Oliver Watkins
  • 12,575
  • 33
  • 119
  • 225

0 Answers0