首页 > 解决方案 > 使用 maven 项目配置 junit

问题描述

我有一个 Maven 项目,它有以下 pom

<dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
            <type>jar</type>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.7</version>
            <type>jar</type>
        </dependency>


    </dependencies>

和下面提到的 maven-compiler-plugin :

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

每当我构建我的项目时,由于 maven-compiler-plugin ,都会安装 Junit 4.12 版本。

问题

我不想配置 Junit 4.12,因为测试与 Junit 4.12 并行运行,这是我不想要的。

标签: mavenjunit

解决方案


我无法重现你的情况。maven-compiler-plugin 在依赖项中没有 junit。因为它,你不可能得到 Junit 4.12。

跑去mvn dependency:tree看看你在哪里得到它。


推荐阅读