Maven的测试过程中的persistence.xml未找到 [英] persistence.xml not found during maven testing
问题描述
我想一个Maven构建进行集成测试过程中,测试数据加载到测试数据库。 persistence.xml中被复制到目标/测试类/ META-INF /
正确的,但我得到的时候测试运行此异常。
I'm trying to load test data into a test DB during a maven build for integration testing. persistence.xml is being copied to target/test-classes/META-INF/
correctly, but I get this exception when the test is run.
javax.persistence.PersistenceException:
没有持久性提供
EntityManager的一个名为aimDatabase
javax.persistence.PersistenceException: No Persistence provider for EntityManager named aimDatabase
这看起来像是没有找到或装载的persistence.xml。
It looks like it's not finding or loading persistence.xml.
推荐答案
只是一个基于Maven的/ Eclipse的JPA项目解决了同样的问题。
Just solved the same problem with a Maven/Eclipse based JPA project.
我有我的META-INF目录下的的src / main / JAVA
与concequence,它没有在测试阶段之前复制到目标目录。
I had my META-INF directory under src/main/java
with the concequence that it was not copied to the target directory before the test phase.
这个目录移动到的src / main /资源
解决了这个问题,并确保了 META-INF / persistence.xml中
文件是目标/班present
当测试运行。
Moving this directory to src/main/resources
solved the problem and ensured that the META-INF/persistence.xml
file was present in target/classes
when the tests were run.
我的认为的是,JPA面把我的 META-INF / persistence.xml中
文件中的的src / main / java的
,这竟然是我的问题的根源。
I think that the JPA facet put my META-INF/persistence.xml
file in src/main/java
, which turned out to be the root of my problem.
这篇关于Maven的测试过程中的persistence.xml未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!