首页 > 解决方案 > maven-surefire-plugin:2.18.1:测试失败

问题描述

我正在学习“Java 中的云原生应用程序”,并且正在做本书中的练习。这是我的 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>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.3.RELEASE</version>
  </parent>
  <groupId>com.mycompany.petstore</groupId>
  <artifactId>product</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
  <dependencies>                    
    <dependency>                                    
    <groupId>org.springframework.boot</groupId>                                 
     <artifactId>spring-boot-starter-web</artifactId>           
        </dependency>
  </dependencies>   
  <build>

    <plugins>

        <plugin>                                                    
            <groupId>org.springframework.boot</groupId>                                                 
            <artifactId>spring-boot-maven-plugin</artifactId>   
        </plugin>
    </plugins>

  </build>
</project>

我在特定路径上设置了 Maven 的设置:C:\Users\Sam.m2\settings.xml

我在 settings.xml 上设置的唯一信息如下:

...
  <proxies>             
    <proxy>                     
        <id>myproxy</id>                        
        <active>true</active>                           
        <protocol>http</protocol>                           
        <host>localhost:8080</host> 
        <nonProxyHosts>localhost,127.0.0.1</nonProxyHosts>      
        <port>8080</port>                                                                           
    </proxy>    
  </proxies>

当我尝试运行这个程序(一个包含三个 java 类的简单程序)时,在我的控制台中有:

 --- maven-surefire-plugin:2.18.1:test (default-test) @ product ---
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/maven-surefire-common/2.18.1/maven-surefire-common-2.18.1.pom
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-api/2.18.1/surefire-api-2.18.1.pom
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-toolchain/2.2.1/maven-toolchain-2.2.1.pom
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/maven-plugin-annotations/3.3/maven-plugin-annotations-3.3.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.873 s
[INFO] Finished at: 2019-07-21T15:32:13+02:00
[INFO] Final Memory: 18M/224M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project product: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: Plugin org.apache.maven.plugins:maven-surefire-plugin:2.18.1 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-surefire-plugin:jar:2.18.1 -> org.apache.maven.surefire:maven-surefire-common:jar:2.18.1: Failed to read artifact descriptor for org.apache.maven.surefire:maven-surefire-common:jar:2.18.1: Could not transfer artifact org.apache.maven.surefire:maven-surefire-common:pom:2.18.1 from/to central (https://repo.maven.apache.org/maven2): localhost:8080 -> [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

我该如何解决这个问题?

标签: javamavenspring-bootdependenciesmaven-surefire-plugin

解决方案


推荐阅读