gpt4 book ai didi

java - 为什么我的 Maven Surefire 插件被忽略?

转载 作者:行者123 更新时间:2023-12-02 06:58:35 25 4
gpt4 key购买 nike

我使用 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>

最佳答案

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

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

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

关于java - 为什么我的 Maven Surefire 插件被忽略?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16983797/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com