Jakarta ee 如何在运行测试用例时排除maven依赖关系

Jakarta ee 如何在运行测试用例时排除maven依赖关系,jakarta-ee,glassfish,ejb,jboss-arquillian,glassfish-embedded,Jakarta Ee,Glassfish,Ejb,Jboss Arquillian,Glassfish Embedded,我在ejb3上工作,并与arqullian一起测试。 我在pom.xml中有以下依赖项 <dependency> <groupId>org.glassfish.main.ejb</groupId> <artifactId>javax.ejb</artifactId> </dependency> <dependency> <groupId&

我在ejb3上工作,并与arqullian一起测试。 我在pom.xml中有以下依赖项

  <dependency>
        <groupId>org.glassfish.main.ejb</groupId>
        <artifactId>javax.ejb</artifactId>
    </dependency>

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
    </dependency>


    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.jboss.arquillian.container</groupId>
        <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.glassfish.main.extras</groupId>
        <artifactId>glassfish-embedded-all</artifactId>
        <version>3.1.2</version>
        <scope>test</scope>
    </dependency>

org.glassfish.main.ejb
javax.ejb
爪哇
JavaEEAPI
org.jboss.arquillian.junit
arquillian junit容器
测试
org.jboss.arquillian.container
arquillian-glassfish-embedded-3.1
测试
org.glassfish.main.extras
玻璃鱼嵌入所有
3.1.2
测试
在运行测试用例时,我需要排除前两个依赖项,但它将在测试时间之外可用

如何才能做到这一点


非常感谢您的帮助

我相信您可以单独使用
javaeeapi
依赖项,因为您可以从它获得ejbapi。但是,您应该将它指定为具有
提供的
范围的依赖项,因为它只能用于编译测试,并且在运行时由容器(在本例中为嵌入式GlassFish)提供


如果您遇到javaee api的问题,您可以尝试使用,因为它们不包含任何精简的方法体,而这些方法体通常是
javaee api
依赖项问题的根源。

当您有javaee 6时,您需要有完整的javaee api,比如Vinet编写,而不是javaee本身。对于JavaEE7,JavaEEAPI依赖关系足以编译。但您需要有JavaEEAPI来编译代码,并且它必须为JavaEE依赖项提供作用域(这意味着Maven使用它进行编译,但不会将JAR添加到归档中,因为容器提供了JAR),并且可能会删除EJB的依赖项

这是我的JBoss和JavaEE7工作示例。这些依赖项足以使用嵌入式容器运行Arqullian:

<dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-arquillian-container-embedded</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-embedded</artifactId>
        <scope>test</scope>
    </dependency>

爪哇
JavaEEAPI
假如
朱尼特
朱尼特
测试
org.jboss.arquillian.junit
arquillian junit容器
测试
野生蝇
wildfly arquillian嵌入式容器
测试
野生蝇
野蝇嵌入
测试
下面是JavaEE6规范API的依赖关系管理。我将其用于Arqullian测试,而不是JavaEEAPI

    <dependency>
        <groupId>org.jboss.spec</groupId>
        <artifactId>jboss-javaee-6.0</artifactId>
        <version>1.0.0.Final</version>
        <scope>provided</scope>
        <type>pom</type>
    </dependency>

org.jboss.spec
jboss-javaee-6.0
1.0.0.1决赛
假如
聚甲醛