多模块项目。
在我的 ejb 模块中,我有突出显示的文件。我想使用相同的文件在 web 模块中运行 arquillian 测试。
在 web 模块的 pom.xml 文件中,我依赖于 ejb 模块,但是提供了范围,因为我不希望从 ejb 模块中获取“真实的”persistence.xml。
<dependency>
<groupId>com.comp</groupId>
<artifactId>g4tc-ejb</artifactId>
<type>ejb</type>
<!-- Use scope provided as we are creating an ear file, and we do not want the packaged jar file in test, as we want the test-persistence.xml -->
<scope>provided</scope>
</dependency>
所以在 RestTest 类中,我想包含来自 ejb 模块的文件..
@Deployment
public static WebArchive getDeployment() {
File[] files = Maven.resolver().loadPomFromFile("pom.xml")
.importRuntimeAndTestDependencies().resolve().withTransitivity().asFile();
WebArchive war = ShrinkWrap.create(WebArchive.class, "g4tcRestWebservice.war")
.addAsLibraries(files)
.addPackages(true, "com.comp.g4tc.web")
.addPackages(true, "com.comp.g4tc.ejb") /* Load the classes from the ejb module instead of through dependency to avoid getting
the g4tc-ejb/src/java/resources/META-INF/persistence.xml, we want the one from the test package */
.addAsResource( "HERE AT THE test-persistence.xml FROM THE EJB MODULE", "META-INF/persistence.xml");
System.out.println(war.toString(true));
return war;
}
这样做的最佳方法是什么。?? 谢谢