Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on ...

 1 [INFO] Scanning for projects...
 2 [INFO] 
 3 [INFO] -----------------------< com.sharp:sharp-common >-----------------------
 4 [INFO] Building sharp-common 0.0.1-SNAPSHOT
 5 [INFO] --------------------------------[ jar ]---------------------------------
 6 [INFO] 
 7 [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ sharp-common ---
 8 [INFO] Deleting G:\worksheet\sharp-common\target
 9 [INFO] 
10 [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ sharp-common ---
11 [INFO] Using 'UTF-8' encoding to copy filtered resources.
12 [INFO] Copying 1 resource
13 [INFO] Copying 0 resource
14 [INFO] 
15 [INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ sharp-common ---
16 [INFO] Changes detected - recompiling the module!
17 [INFO] Compiling 1 source file to G:\worksheet\sharp-common\target\classes
18 [INFO] 
19 [INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ sharp-common ---
20 [INFO] Using 'UTF-8' encoding to copy filtered resources.
21 [INFO] skip non existing resourceDirectory G:\worksheet\sharp-common\src\test\resources
22 [INFO] 
23 [INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ sharp-common ---
24 [INFO] Changes detected - recompiling the module!
25 [INFO] Compiling 1 source file to G:\worksheet\sharp-common\target\test-classes
26 [INFO] 
27 [INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ sharp-common ---
28 [WARNING] The POM for org.apache.maven.reporting:maven-reporting-api:jar:3.0 is missing, no dependency information available
29 [INFO] ------------------------------------------------------------------------
30 [INFO] BUILD FAILURE
31 [INFO] ------------------------------------------------------------------------
32 [INFO] Total time: 1.759 s
33 [INFO] Finished at: 2018-11-27T17:50:15+08:00
34 [INFO] ------------------------------------------------------------------------
35 [WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
36 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project sharp-common: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test failed: Plugin org.apache.maven.plugins:maven-surefire-plugin:2.22.1 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-surefire-plugin:jar:2.22.1 -> org.apache.maven.surefire:maven-surefire-common:jar:2.22.1 -> org.apache.maven.plugin-tools:maven-plugin-annotations:jar:3.5.2: Failed to read artifact descriptor for org.apache.maven.plugin-tools:maven-plugin-annotations:jar:3.5.2: Failure to find org.apache.maven.plugin-tools:maven-plugin-tools:pom:3.5.2 in http://192.168.135.128:8081/repository/maven-public/ was cached in the local repository, resolution will not be reattempted until the update interval of my-nenux has elapsed or updates are forced -> [Help 1]
37 [ERROR] 
38 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
39 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
40 [ERROR] 
41 [ERROR] For more information about the errors and possible solutions, please read the following articles:
42 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

修改前pom

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 4     <modelVersion>4.0.0</modelVersion>
 5 
 6     <parent>
 7         <groupId>com.sharp</groupId>
 8         <artifactId>sharp-pom</artifactId>
 9         <version>0.0.1-SNAPSHOT</version>
10     </parent>
11     <artifactId>sharp-common</artifactId>
12     <packaging>jar</packaging>
13 
14     <name>sharp-common</name>
15     <description>公共模块</description>
16 
17 
18     <dependencies>
19      <dependency>
20          <groupId>org.springframework.boot</groupId>
21          <artifactId>spring-boot-starter</artifactId>
22       </dependency>
23  
24       <dependency>
25          <groupId>org.springframework.boot</groupId>
26          <artifactId>spring-boot-starter-test</artifactId>
27          <scope>test</scope>
28       </dependency>
29     </dependencies>
30      <build>
31       <plugins>
32          <plugin>
33             <groupId>org.springframework.boot</groupId>
34             <artifactId>spring-boot-maven-plugin</artifactId>
35          </plugin>
36       </plugins>
37    </build>
38     <distributionManagement>
39         <repository>
40             <id>my-release</id>
41             <url>http://xxxxxx:8081/repository/maven-releases/</url>
42         </repository>
43         <snapshotRepository>
44             <id>my-snapshots</id>
45             <url>http://xxxxxxx:8081/repository/maven-snapshots/</url>
46         </snapshotRepository>
47     </distributionManagement>
48 </project>

添加如下代码:<version>2.6</version> 信息缺失就会上述错误要注意

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

变为

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 4     <modelVersion>4.0.0</modelVersion>
 5 
 6     <parent>
 7         <groupId>com.sharp</groupId>
 8         <artifactId>sharp-pom</artifactId>
 9         <version>0.0.1-SNAPSHOT</version>
10     </parent>
11     <artifactId>sharp-common</artifactId>
12     <packaging>jar</packaging>
13 
14     <name>sharp-common</name>
15     <description>公共模块</description>
16 
17 
18     <dependencies>
19      <dependency>
20          <groupId>org.springframework.boot</groupId>
21          <artifactId>spring-boot-starter</artifactId>
22       </dependency>
23  
24       <dependency>
25          <groupId>org.springframework.boot</groupId>
26          <artifactId>spring-boot-starter-test</artifactId>
27          <scope>test</scope>
28       </dependency>
29     </dependencies>
30      <build>
31       <plugins>
32          <plugin>
33             <groupId>org.springframework.boot</groupId>
34             <artifactId>spring-boot-maven-plugin</artifactId>
35          </plugin>
36          <plugin> 
37             <groupId>org.apache.maven.plugins</groupId> 
38             <artifactId>maven-surefire-plugin</artifactId> 
39             <version>2.6</version>    
40             <configuration>    
41             <skipTests>true</skipTests>    
42             </configuration> 
43             </plugin>
44       </plugins>
45    </build>
46     <distributionManagement>
47         <repository>
48             <id>my-release</id>
49             <url>http://192.168.135.128:8081/repository/maven-releases/</url>
50         </repository>
51         <snapshotRepository>
52             <id>my-snapshots</id>
53             <url>http://192.168.135.128:8081/repository/maven-snapshots/</url>
54         </snapshotRepository>
55     </distributionManagement>
56 </project>

然后再次 clean install/deploy成功

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
`failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4` 这个错误信息通常出现在使用 Maven 构建 Java 项目时。Maven Surefire 插件是 Maven 中用于运行单元测试的插件,版本 2.12.4 是该插件的一个具体版本。当这个错误出现时,它表明在执行单元测试的过程中发生了问题。 这个错误可能是由多种原因导致的,比如: 1. 项目中没有包含任何测试文件,或者测试文件的命名和格式不正确,导致 Surefire 插件没有找到可执行的测试。 2. 测试依赖没有正确配置,或者存在与主程序依赖冲突的情况,导致测试执行时出现问题。 3. 编码问题或运行时环境不兼容问题,例如 JRE 版本与项目要求的版本不匹配。 4. 测试代码本身存在错误,比如测试方法的编写不规范等。 5. 在执行过程中,插件可能因为权限问题或其他外部因素导致执行失败。 要解决这个问题,可以尝试以下步骤: 1. 检查项目中是否存在正确的测试文件,并确保它们遵循了正确的命名规则(通常是`*Test.java`)。 2. 检查项目的 `pom.xml` 文件,确保测试相关的依赖被正确声明。 3. 确保构建环境的 JRE 版本与项目兼容,可以尝试更新或降级 JRE 版本。 4. 查看详细的错误输出,它通常会提供更具体的错误信息来帮助定位问题。 5. 如果是在持续集成环境中遇到的问题,检查环境配置和权限设置是否正确。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值