【发布时间】:2026-02-07 12:40:01
【问题描述】:
我是这样添加插件的:
<maven.surefire.version>3.0.0-M5</maven.surefire.version>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<parallel>methods</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
</configuration>
</plugin>
……一切顺利。
我将版本更改为 2.22.2 并收到错误:Plugin 'org.apache.maven.plugins:maven-surefire-plugin:2.22.2' not found。
但是,当我在 IntelliJ 中进行工件搜索时,它确实找到了那个版本。好的,我将更改恢复到原来的版本。
现在,当我运行 mvn test 时,以下内容引起了我的注意:
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ regression-tests ---
为什么不使用 3.0.0-M5? 2.12.4 来自哪里?我在我的 pom.xml 中搜索了“surefire”,但除了上面显示的内容之外,没有出现其他命中。
查看 IntelliJ 的 Preferences,我发现正在使用的 repo 是 https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/,所有提到的版本都在那里。
有人可以向我解释发生了什么吗?为什么找不到 2.22.2?为什么在 pom.xml 中显示使用的是 2.12.4 而 3.0.0-M5?
为了完整起见,这是我的 mvn:
❯ mvn --version
Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)
Maven home: /opt/homebrew/Cellar/maven/3.8.2/libexec
Java version: 1.8.0_292, vendor: Azul Systems, Inc., runtime: /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "11.5.2", arch: "aarch64", family: "mac"
【问题讨论】:
标签: maven intellij-idea maven-surefire-plugin