【问题标题】:JBoss ShrinkWrap. Adding file from other module.JBoss 收缩包装。从其他模块添加文件。
【发布时间】:2015-11-17 19:43:29
【问题描述】:

多模块项目。

在我的 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;
}

做到这一点的最佳方法是什么。 ??谢谢

【问题讨论】:

    标签: jboss dependencies shrinkwrap


    【解决方案1】:

    通过检查 ejb/target/classes 来检查是否可以在类路径中找到这些文件是一种快速而肮脏的方法。如果是这种情况,只需添加:

    .addAsResource(g4TravelCenterTest-ds.xml)
    .addAsResource(import.sql)
    .addAsResource(META-INF/test-persistence.xml)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-13
      • 1970-01-01
      • 2017-10-05
      • 2021-11-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多