且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

单元测试期间未扫描JPA实体

更新时间:2023-02-14 17:31:58

我通过通过ant运行junit测试来使其工作.我将persistence.xml文件复制到build/classes/META-INF,以便将其与已编译实体类放在同一文件夹树中,这使得扫描能够正常进行,并且测试能够正确运行.

I got it working by running the junit test via ant. I copied the persistence.xml file to build/classes/META-INF so that it would be in the same folder tree as the compiled entity classes and this allowed scanning to work and the test to run correctly.

如果我删除persistence.xml的Webcontent/WEB-INF/classes/META-INF副本并将其保留在build/文件夹中,则这在Eclipse中有效.我想知道是否有更好的方法可以使其在Eclipse中工作.

This works in Eclipse if I delete the Webcontent/WEB-INF/classes/META-INF copy of persistence.xml and leave it in the build/ folder. I wonder if there's a better way to make it work in Eclipse.