【问题标题】:Why is my maven surefire plugin getting ignored?为什么我的 maven surefire 插件被忽略了?
【发布时间】:2013-06-07 12:10:23
【问题描述】:

我使用 Netbeans 的 Maven 插件 (v4.20.1) 在 Netbeans 7.3 中创建了一个 maven 项目

在我的 pom.xml 中,我尝试明确定义 surefire 插件,但无论我做什么,它都不会选择它。它正在拉不同版本的surefire(2.10),我不确定从哪里开始。 pom.xml 中的所有其他插件都按预期工作。有什么线索吗?

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>myGroup</groupId>
    <artifactId>myArtifact</artifactId>
    <version>myVersion</version>
    <packaging>jar</packaging>
    <name>myName</name>

    <properties>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>        
        <maven.build.timestamp.format>yyyy-MM-dd_HH:mm</maven.build.timestamp.format>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4</version>
                <!--etc...-->
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <!--etc...-->
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <!--etc...-->
            </plugin>

            <plugin>
                <groupId>org.apache.maven.surefire</groupId>
                <artifactId>surefire</artifactId>
                <!-- This invalid version should trigger a maven error, but doesn't -->
                <version>92.14</version>
                <!--etc...-->
            </plugin> 

            <plugin>
                <groupId>com.google.code.maven-replacer-plugin</groupId>
                <artifactId>replacer</artifactId>
                <version>1.5.2</version>
                <!--etc...-->
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.8</version>
            <!--etc...-->
            </plugin>            

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.5</version>
                <!--etc...-->
            </plugin>
        </plugins>

    </build>

    <profiles>
        <profile>
            <id>windows</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <os>
                    <family>windows</family>
                </os>
            </activation>
            <properties>
            <!--etc...-->
            </properties>
        </profile>
        <profile>
            <id>linux</id>
            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>
            <properties>
            <!--etc...-->
            </properties>
        </profile>
    </profiles>

</project>

【问题讨论】:

    标签: java maven netbeans


    【解决方案1】:

    您引用的工件 (org.apache.maven.surefire:surefire) 不是插件,而是 POM。

    您应该使用以下方式更改声明:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                ...
            </plugin> 
    

    【讨论】:

    • 是的,就是这样。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2013-09-30
    • 2016-06-20
    • 1970-01-01
    • 2015-09-22
    • 2018-03-12
    • 1970-01-01
    • 2022-12-23
    • 1970-01-01
    相关资源
    最近更新 更多