未能执行目标 org.apache.maven.plugins: maven-surefire-plugin: 2.10: test

我已经在网上搜索了将近五天来寻找解决这个问题的方法,但是我似乎不能自己找到并解决它,主要是因为我对 Maven 和 PlayN 都是如此的陌生,所以我不能完全确定我到底在看什么。但是,它显然在构建核心方面失败了。似乎它无法下载“工件过滤器”,也无法运行 Surefire 的测试。但是,我只是在推测一些我并不完全理解的事情,尽管我一直在疯狂地研究这些事情。任何来自更有经验的人的帮助都会非常非常感激。我快疯了。

[INFO] Building Synthesis Core 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ synthesis-core ---
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ synthesis-core ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] skip non existing resourceDirectory C:\Users\Josiah\synthesis\core\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3:compile (default-compile) @ synthesis-core ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ synthesis-core ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Josiah\synthesis\core\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3:testCompile (default-testCompile) @ synthesis-core ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ synthesis-core ---
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-common-artifact-filters/1.3/maven-common-artifact-filters-1.3.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Synthesis Metaproject ............................. SUCCESS [1.059s]
[INFO] Synthesis Core .................................... FAILURE [3.538s]
[INFO] Synthesis Java .................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.997s
[INFO] Finished at: Wed Oct 31 23:57:38 EDT 2012
[INFO] Final Memory: 6M/109M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on project synthesis-core: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test failed: Plugin org.apache.maven.plugins:maven-surefire-plugin:2.10 or one of its dependencies could not be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-surefire-plugin:jar:2.10 (): Failed to read artifact descriptor for org.apache.maven.shared:maven-common-artifact-filters:jar:1.3: Could not transfer artifact org.apache.maven.shared:maven-common-artifact-filters:pom:1.3 from/to central (http://repo.maven.apache.org/maven2): Remotely Closed [id: 0x0847a8f3, /192.168.1.54:65153 :> repo.maven.apache.org/93.184.215.223:80] -> [Help 1]

然后,我让它打印整个调试日志,它在 Surefire 位上做了一些详细说明,显示所有调用的 Exception:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
10:test (default-test) on project synthesis-core: Execution default-test of goal
org.apache.maven.plugins:maven-surefire-plugin:2.10:test failed: Plugin org.apa
che.maven.plugins:maven-surefire-plugin:2.10 or one of its dependencies could no
t be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven
-surefire-plugin:jar:2.10 (): Failed to read artifact descriptor for org.apache.
maven.shared:maven-common-artifact-filters:jar:1.3: Could not transfer artifact
org.apache.maven.shared:maven-common-artifact-filters:pom:1.3 from/to central (h
ttp://repo.maven.apache.org/maven2): Connection reset -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on projec
t synthesis-core: Execution default-test of goal org.apache.maven.plugins:maven-
surefire-plugin:2.10:test failed: Plugin org.apache.maven.plugins:maven-surefire
-plugin:2.10 or one of its dependencies could not be resolved: Failed to collect
dependencies for org.apache.maven.plugins:maven-surefire-plugin:jar:2.10 ()
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:225)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-t
est of goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test failed: Plu
gin org.apache.maven.plugins:maven-surefire-plugin:2.10 or one of its dependenci
es could not be resolved: Failed to collect dependencies for org.apache.maven.pl
ugins:maven-surefire-plugin:jar:2.10 ()
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:82)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:209)
... 19 more
Caused by: org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.
maven.plugins:maven-surefire-plugin:2.10 or one of its dependencies could not be
resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-sur
efire-plugin:jar:2.10 ()
at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.re
solve(DefaultPluginDependenciesResolver.java:211)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.createPlug
inRealm(DefaultMavenPluginManager.java:353)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.setupPlugi
nRealm(DefaultMavenPluginManager.java:321)
at org.apache.maven.plugin.DefaultBuildPluginManager.getPluginRealm(Defa
ultBuildPluginManager.java:175)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:78)
... 20 more
Caused by: org.sonatype.aether.collection.DependencyCollectionException: Failed
to collect dependencies for org.apache.maven.plugins:maven-surefire-plugin:jar:2
.10 ()
at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectD
ependencies(DefaultDependencyCollector.java:258)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.collectDepe
ndencies(DefaultRepositorySystem.java:308)
at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.re
solve(DefaultPluginDependenciesResolver.java:199)
... 24 more
Caused by: org.sonatype.aether.resolution.ArtifactDescriptorException: Failed to
read artifact descriptor for org.apache.maven.shared:maven-common-artifact-filt
ers:jar:1.3
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.
loadPom(DefaultArtifactDescriptorReader.java:296)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.
readArtifactDescriptor(DefaultArtifactDescriptorReader.java:186)
at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(
DefaultDependencyCollector.java:412)
at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(
DefaultDependencyCollector.java:544)
at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectD
ependencies(DefaultDependencyCollector.java:240)
... 26 more
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not
transfer artifact org.apache.maven.shared:maven-common-artifact-filters:pom:1.3
from/to central (http://repo.maven.apache.org/maven2): Connection reset
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(Def
aultArtifactResolver.java:538)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArti
facts(DefaultArtifactResolver.java:216)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArti
fact(DefaultArtifactResolver.java:193)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.
loadPom(DefaultArtifactDescriptorReader.java:281)
... 30 more
Caused by: org.sonatype.aether.transfer.ArtifactTransferException: Could not tra
nsfer artifact org.apache.maven.shared:maven-common-artifact-filters:pom:1.3 fro
m/to central (http://repo.maven.apache.org/maven2): Connection reset
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(W
agonRepositoryConnector.java:951)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(W
agonRepositoryConnector.java:941)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.
run(WagonRepositoryConnector.java:669)
at org.sonatype.aether.util.concurrency.RunnableErrorForwarder$1.run(Run
nableErrorForwarder.java:60)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.maven.wagon.TransferFailedException: Connection reset
at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.fillInput
Data(AbstractHttpClientWagon.java:799)
at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:11
6)
at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.
run(WagonRepositoryConnector.java:601)
... 4 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at org.apache.maven.wagon.providers.http.httpclient.impl.io.AbstractSess
ionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:149)
at org.apache.maven.wagon.providers.http.httpclient.impl.io.SocketInputB
uffer.fillBuffer(SocketInputBuffer.java:110)
at org.apache.maven.wagon.providers.http.httpclient.impl.io.AbstractSess
ionInputBuffer.readLine(AbstractSessionInputBuffer.java:264)
at org.apache.maven.wagon.providers.http.httpclient.impl.conn.DefaultRes
ponseParser.parseHead(DefaultResponseParser.java:98)
at org.apache.maven.wagon.providers.http.httpclient.impl.io.AbstractMess
ageParser.parse(AbstractMessageParser.java:252)
at org.apache.maven.wagon.providers.http.httpclient.impl.AbstractHttpCli
entConnection.receiveResponseHeader(AbstractHttpClientConnection.java:281)
at org.apache.maven.wagon.providers.http.httpclient.impl.conn.DefaultCli
entConnection.receiveResponseHeader(DefaultClientConnection.java:247)
at org.apache.maven.wagon.providers.http.httpclient.impl.conn.AbstractCl
ientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:219)
at org.apache.maven.wagon.providers.http.httpclient.protocol.HttpRequest
Executor.doReceiveResponse(HttpRequestExecutor.java:298)
at org.apache.maven.wagon.providers.http.httpclient.protocol.HttpRequest
Executor.execute(HttpRequestExecutor.java:125)
at org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultR
equestDirector.tryExecute(DefaultRequestDirector.java:645)
at org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultR
equestDirector.execute(DefaultRequestDirector.java:464)
at org.apache.maven.wagon.providers.http.httpclient.impl.client.Abstract
HttpClient.execute(AbstractHttpClient.java:820)
at org.apache.maven.wagon.providers.http.httpclient.impl.client.Abstract
HttpClient.execute(AbstractHttpClient.java:754)
at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.execute(A
bstractHttpClientWagon.java:674)
at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.fillInput
Data(AbstractHttpClientWagon.java:793)
... 8 more

编辑: 为分析添加 pom.xml。

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.googlecode.playn</groupId>
<artifactId>playn-project</artifactId>
<version>1.3.1</version>
</parent>


<groupId>com.hijackedlongboat</groupId>
<artifactId>synthesis</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Synthesis Metaproject</name>


<properties>
<playn.version>1.3.1</playn.version>
</properties>


<profiles>
<profile>
<id>java</id>
<activation><activeByDefault>true</activeByDefault></activation>
<modules><module>java</module></modules>
</profile>
<profile>
<id>android</id>
<modules><module>android</module></modules>
</profile>
<profile>
<id>ios</id>
<modules><module>ios</module></modules>
</profile>
<profile>
<id>html</id>
<modules><module>html</module></modules>
</profile>
<profile>
<id>flash</id>
<modules><module>flash</module></modules>
</profile>
</profiles>


<modules>
<module>core</module>
</modules>
</project>

编辑2: 解决 通过使用命令“ mvn Depency: : tree”,我能够找到一个缺失的存储库,它没有在调试和堆栈跟踪中显示出来。缺少的存储库是“ forplay-Heritage”,然后我将其添加到 pom.xml 中,如下所示:

  <repositories>
<repository>
<id>forplay-legacy</id>
<url>http://forplay.googlecode.com/svn/mavenrepo</url>
</repository>
</repositories>
552171 次浏览

你可能遗漏了一些依赖关系。

使用 mvn dependency:tree找到缺少的依赖项,然后手动安装它们,并使用 -o(脱机)选项构建项目。

更新 Maven 项目:

步骤:

  1. 右键点击“项目”
  2. 点击“美芬”> “更新”
  3. 等待应用所有更改
  4. 提交更改(如果代码在回购中)
  5. 快跑

我有类似的问题,我能够解决它使用-U 选项与 mvn 命令作为

mvn clean install -U

这招对我很管用,希望能有帮助。

当我遇到这个问题时,changes.xml文档格式不正确(缺少一个结束标记)。修复方法是编辑 XML,使其格式良好。

因此,检查 XML 是否结构良好的 可以是非常重要,特别是当发布插件没有抱怨它的时候。

对我来说,改变詹金斯的版本有所帮助。

  <parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.642.4</version><!-- which version of Jenkins is this plugin built against? -->
</parent>

我面临同样的错误,但在我的情况下,问题在删除 /target文件夹和 nbactions.xml文件后得到解决。

如果某些单元测试用例失败,就会发生此错误。

在我的应用程序中,某些单元测试与 Java8不兼容,因此它们会失败。将 jdk1.8.0_92改为 jdk1.7.0_80后,我的错误得到了解决。

使用 mvn clean install -DskipTests构建将会成功,但是这将跳过单元测试。所以只要确保在构建完成之后分别运行即可。

我也遇到过类似的问题,但这里所有的答案都没有帮助到我。

对我来说,问题是考试不及格。如果您正在进行测试驱动开发,那么一个失败的或者没有实现的测试不应该破坏构建。我仍然希望我的项目建设。

为了解决这个问题,我添加了一个 sure fire 配置,这样它就可以忽略失败的测试。

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>

有时你会得到类似的发音错误,但原因真的不相关的工具-在这种情况下,Surefire 插件。

对我来说,我得到了类似的错误,但原因是我没有指向正确的数据库网址!

在许多冗长的内容中(使用 mvn-X 标志) ,我看到了一条超时消息。

我使用的一个技巧是在构建服务器上安装 IntelliJ (用于调试目的) ,并首先通过它解决问题,然后卸载它,并确保在构建服务器上一切正常。

我也有同样的问题,我从以下几个步骤中解决了:

  1. 右键单击 project-> maven-> Update project
  2. 这里我选择了“强制更新快照/发布”
  3. 之后,我再次编译我的项目和问题得到解决

Right Click on Project -> Maven -> Update Project -> Select Force update of snapshot

或者

导航到项目根文件夹并使用以下命令:

Mvn clean install-U 或者 Mvn clean install —— update ——快照

Here-U 将强制检查远程存储库上缺少的版本和更新的快照

我尝试按照这个帖子上大多数评论中给出的说明进行操作,包括选择的答案,但错误仍然存在。我做了一些研究,发现这个 呼叫给出了一个解决方案,帮助我(好吧,虽然我的一部分猜测)。

所以我所做的就是替换了 maven surefire 插件中的版本号,如下所示: < groupId > org.apache.maven.plugins < artifactId > maven-surefire-plugin < version > 3.0.0-M1

希望这个能帮上忙!

我也遇到过类似的问题,我的解决方案与其他用户发布的完全不同。

我的问题与我去年工作的项目有关,这个项目需要在 maven 设置上使用某个代理(位于 <path to maven folder>\maven\conf\settings.xmlC:\Users\<my user>\.m2\settings.xml)。代理阻止了所需外部包的下载。

解决方案是将原始文件(settings.xml)放回这些位置。一旦东西恢复了,我就能下载软件包,一切都正常了。

请遵循以下教程: Https://www.petrikainulainen.net/programming/maven/creating-code-coverage-reports-for-unit-and-integration-tests-with-the-jacoco-maven-plugin/

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<!-- Sets the VM argument line used when unit tests are run. -->
<argLine>${surefireArgLine}</argLine>
<!-- Skips unit tests if the value of skip.unit.tests property is true -->
<skipTests>${skip.unit.tests}</skipTests>
<!-- Excludes integration tests when unit tests are run. -->
<excludes>
<exclude>**/IT*.java</exclude>
</excludes>
</configuration>