Dom*_*nik 9 java jpa build maven
如果我将persistence.xml放在src/test/META-INF文件夹中,则自动检测实体不能与maven-verify一起使用.当persistence.xml位于src/main/META-INF文件夹中时,它可以正常工作.
在两种情况下都可以在eclipse中运行测试.
当persistence.xml位于src/test文件夹中时,有没有办法让autodetection用于maven-verify?
persistence.xml中:
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name="Unit" transaction-type="RESOURCE_LOCAL">
<properties>
<!-- Scan for annotated classes and Hibernate mapping XML files -->
<property name="hibernate.archive.autodetection" value="class" />
</properties>
</persistence-unit>
</persistence>
Run Code Online (Sandbox Code Playgroud)
axt*_*avt 21
默认情况下,自动检测适用于同一类路径项中的实体persistence.xml
.它可以由<jar-file>
元素配置.
为了persistence.xml
在src/test/resources/META-INF
我使用时启用正确的自动检测,我使用以下技巧:
persistence.xml
:
<persistence ...>
<persistence-unit ...>
<jar-file>${project.build.outputDirectory}</jar-file>
...
</persistence-unit>
</persistence>
Run Code Online (Sandbox Code Playgroud)
pom.xml
- 启用资源过滤src/test/resources
:
<project ...>
...
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
虽然我确实如何使用它,但如果你persistence.xml
真的在src/test/META-INF
.
归档时间: |
|
查看次数: |
8023 次 |
最近记录: |