【问题标题】:Maven Build Failure with "mvn install" command使用“mvn install”命令的 Maven 构建失败
【发布时间】:2019-06-28 22:14:03
【问题描述】:

我试图为 Cucumber-Maven 报告生成和测试我的代码(如果有效),然后打开命令提示符。我试过“mvn clean”,它是建立成功的。之后,我尝试了“mvn install”并遇到了BUILD FAILURE(显示错误)。

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  22.844 s
[INFO] Finished at: 2019-02-05T13:14:51+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-surefire-plugin:2.20 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-surefire-plugin:jar:2.20: Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.20 from/to central (https://repo.maven.apache.org/maven2): Connect to webproxy.sample.com:8080 [webproxy.sample.com/205.165.7.13] failed: Connection timed out: connect -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

这是我的 pom.xml:

  <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
            <source>1.8</source>
            <target>1.8</target>
            </configuration>
        </plugin>

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

        <plugin>
            <groupId>net.masterthought</groupId>
            <artifactId>maven-cucumber-reporting</artifactId>
            <version>4.3.0</version>
            <executions>
                <execution>
                    <id>execution</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>

                    <projectName>ExecuteCucumberMavenAF</projectName>
                    <outputDirectory>${project.build.directory}/cucumber-reports-html</outputDirectory>
                    <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
                    <skippedFails>true</skippedFails>
                    <enableFlashCharts>true</enableFlashCharts>
                    <buildNumber>42</buildNumber>
                </configuration>
            </execution>
        </executions>
    </plugin>   
</plugins>  
</build>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

【问题讨论】:

  • 看起来你的代理有误:连接到 webproxy.sample.com:8080 [webproxy.sample.com/205.165.7.13] 失败:连接超时:连接
  • 您应该在 setting.xml 中检查并更新您的代理。
  • 恕我直言,万无一失的版本控制只有三个部分。因此版本不是 2.22 而是 2.22.0。顺便说一句 2.22.1 已经出来了。
  • @Jens 我在 settings.xml 中有我的代理,但我仍然遇到此错误:插件 org.apache.maven.plugins:maven-surefire-plugin:2.22.0 或其依赖项之一无法已解决:无法读取 org.apache.maven.plugins:maven-surefire-plugin:jar:2.22.0 的工件描述符:无法传输工件 org.apache.maven.plugins:maven-surefire-plugin:pom:2.22 .0 from/to central (repo.maven.apache.org/maven2): 连接超时 -> [帮助 1]
  • @vivekdubey 我在 settings.xml 中有我的代理,但我仍然遇到错误。我真的需要为自动化项目设置代理吗?我当时使用的代理来自我的公司。如果我在家里运行我的自动化框架,我将如何处理该代理?

标签: java maven cmd automation maven-surefire-plugin


【解决方案1】:

这看起来像是代理问题,它阻止了依赖项的下载,因此请在 settings.xml 中进行一些更改,如果不存在则创建一个。

转到c:\users\youruser\.m2\settings.xml.

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                              http://maven.apache.org/xsd/settings-1.0.0.xsd">

 <proxies>
    <proxy>
      <id>myproxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>user</username>  <!-- Put your username here -->
      <password>pass</password>  <!-- Put your password here -->
      <host>123.45.6.78</host>   <!-- Put the IP address of your proxy server here -->
      <port>80</port>            <!-- Put your proxy server's port number here -->
      <nonProxyHosts>maven</nonProxyHosts> <!-- Do not use this setting unless you know what you're doing. -->
    </proxy>    
  </proxies> 
</settings>

【讨论】:

  • 如果代理没有用户名和密码,我应该留空还是评论?
  • @AutomationEngineer ,留空。
  • 我真的需要为自动化项目设置代理吗?我当时使用的代理来自我的公司。如果我在家里运行我的自动化框架,我将如何处理该代理?
  • 单击开始,单击运行,键入cmd,然后单击确定。在命令提示符处,键入 netsh winhttp reset proxy,然后按 ENTER
  • 结果:写入代理设置时出错。 (5) 访问被拒绝。当前 WinHTTP 代理设置:直接访问(无代理服务器)。
【解决方案2】:

我尝试使用 Eclipse。我对同一个 POM 文件使用了 maven clean 和 install 。它工作正常。

您的C:\users\youruser\.m2\settings.xml 文件似乎有问题。 可能是阻止 maven 下载依赖项的代理问题。 请检查您的 settings.xml 文件。

【讨论】:

  • 从不指定硬编码路径,而是尝试提供线索,以便用户可以根据自己的 PC 设置进行更改。
  • @Debi P 我在 settings.xml 中有我的代理,但我仍然遇到错误。我真的需要为自动化项目设置代理吗?我当时使用的代理来自我的公司。如果我在家里运行我的自动化框架,我将如何处理该代理?
猜你喜欢
  • 1970-01-01
  • 2015-07-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-26
  • 1970-01-01
  • 2016-05-17
  • 2012-12-04
相关资源
最近更新 更多