无法执行目标org.apache.maven.plugins:maven-surefire-plugin:2.10:test


132

我已经在互联网上搜寻了将近五天的时间,以寻求解决此问题的方法,但是我似乎无法自己找到并解决它,主要是因为我对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位上进行了详细说明,显示了所有调用的异常:

[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依赖关系:: tree”,我能够找到一个未显示在调试和堆栈跟踪上的丢失的存储库。缺少的存储库是“ forplay-legacy”,然后我将其添加到pom.xml中,如下所示:

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

向我们展示最重要的部分,即pom.xml。这样我们也许可以提供帮助。
maba 2012年

我的宝 先生,您真好。现在编辑我的帖子添加进去。
DoctorDep

3
@ user1784668我们如何知道缺少哪一个?
Sourabh Saldi 2015年

mvn install为我解决了问题,它安装了所有依赖项
vikramvi

Answers:


57

您可能缺少一些依赖项。

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


我无法想象笔记本电脑通过自己的家庭wifi连接到互联网有什么麻烦。我的防火墙也在安全路由器下关闭。不过,您的观点是正确的,因此,我肯定会试一试,然后将结果写回去。
DoctorDep 2012年

4
哦,天哪,非常感谢。这不是我的Internet的问题,但是在您在评论中告诉我之前,我还不知道“ mvndependency :: tree”命令,这导致我找到了一个缺少的存储库,因为它没有提供debug和stack trace命令。不向我展示。缺少的存储库是“ forplay-legacy”。然后,我对该存储库进行了一些谷歌搜索,并找到了一些信息,然后将其添加到了我的存储库列表中。而且,瞧,它安装正确。如果您没有提到该命令,我将永远找不到。非常感谢你!
DoctorDep 2012年

2
好!!这个技巧也帮助了我。我不知道为什么UI(Maven-> Update Project)可以帮助我。
阿米特·库玛·古普塔

哈哈,我完全忘记了-o,快照也不会更新。感谢您的提醒!
乔纳森·娜蒂·克洛珀

2
Pratik在下面的答案是mvn clean install -U,这是更容易解决的问题。
亚历山大·措施

69

我有类似的问题,我可以使用-U选项以及mvn命令解决它

mvn clean install -U

这对我有用,希望对您有所帮助。


2
-U做什么?
Spikolynn

5
@ Spikolynn,-U重新下载所有依赖项
Jason Washo

使用Eclipse:右键单击项目>运行方式> maven clean ..这对我有用
Debuggerrr

21

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

对我来说,问题是测试失败。如果您要进行测试驱动的开发,那么失败/未实现的测试不应破坏构建。我仍然希望我的项目能够构建。

为了解决这个问题,我在surefire中添加了一个配置,以便它忽略测试失败。

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

7
我认为这不是一个好主意。所做的更改是将此更改签入SCM,然后您的CI服务器将不会捕获代码中的错误。
britter

2
@britter并不意味着它会忽略错误(失败的测试)。只有在测试失败时,它才不会破坏构建。使用测试驱动样式,在CI服务器上也可以。您仍然可以对失败的测试执行任何操作,并查看失败的测试。
Spenhouet

1
像答案一样完全是错误的:它不允许testFailure解决问题
Hohenheim

11

更新Maven项目:

脚步:

  1. 右键单击“项目”
  2. 转到“ Maven” >>“更新”
  3. 等待所有更改被应用
  4. 提交更改(如果代码在仓库中)

10

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

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

构建将成功完成,mvn clean install -DskipTests但这将跳过单元测试。因此,只需确保在构建完成后分别运行即可。


是的,我也是如此。测试用例失败,因此我们得到了提到的错误
Chaklader Asfak Arefe

5

我尝试按照此线程上大多数注释中给出的说明进行操作,包括选择的答案,但错误仍然存​​在。我进行了一些研究,发现此页面提供了可以帮助我解决问题的解决方案(好吧,尽管有部分猜测)。

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

我希望这有帮助!


1

我遇到了同样的错误,但就我而言,删除/target文件夹和nbactions.xml文件后问题得以解决。


以我为例-只需/target从高级文件夹中删除文件夹,所有子文件夹都可以完成操作。
安德烈·列别登科

1

我遇到了同样的问题,可以通过以下步骤解决:

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

0

遇到问题时,changes.xml文档格式错误(缺少结束标记)。解决方法是编辑XML以使其格式正确。

因此,检查XML格式是否正确很重要,尤其是在发行插件没有抱怨的情况下。


0

对于我来说,更改Jenkins版本会有所帮助。

  <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>

0

有时您会收到类似的听起来错误,但由于与工具无关的原因-在这种情况下为Surefire插件。

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

在很多详细信息中(使用mvn -X标志),我看到了超时消息。

我做过的一个技巧是在构建服务器上安装IntelliJ(出于调试目的),并先通过它解决问题,然后再卸载它,并确保所有内容也能在构建服务器上正常工作。


0

右键单击项目-> Maven->更新项目->选择强制更新快照

要么

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

mvn全新安装-U或mvn全新安装--update-snapshots

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


0

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

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

解决方案是将原始文件(settings.xml)放回这些位置。恢复一切后,我便能够下载软件包,并且一切正常。


0

请按照以下教程操作: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>

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.