So, src/test/resources/META-INF/persistence.xml file needs to be output to the ‘java classes’ directory. The reason for this is JPA providers scan the directory or jar that the persistence.xml file exists in. This means if the persistence.xml file is in a resources directory with no classes, it finds no entities and doesn’t load them.
soooo, I see two ways of resolving this both of which I am not sure how to do in gradle 5.
- move src/test/resources/META-INF/persistence.xml to src/test/java/META-INF/persistence.xml AND modify gradle so it not only compiles code from src/test/java BUT also copies over the persistence.xml to the output of test classes
- modify gradle to copy over META-INF/persistence.xml into the test classes directory
Is 1 or 2 better? What will work more long term for gradle since the previous solution broke when upgrading to 5.0 (I am hoping to not have to keep fixing/changing this).
thanks,
Dean