Java学习笔记之一:打包报错解决Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test

博主在尝试打包Java项目时遇到测试失败问题,通过修改pom.xml添加maven-surefire-plugin配置,将测试跳过并最终成功打包。详细介绍了解决过程和关键代码片段。

学Java打包时报错

...
Tests in error: 
  testAddEmployee(com.xxxx.oa.organ.service.EmployeeServiceTest): Failed to load ApplicationContext

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.223 s
[INFO] Finished at: 2021-11-27T20:44:05+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project oa-organ: There are test failures.
[ERROR] 
[ERROR] Please refer to E:\Develop\eclipse\workspace\oa-organ\target\surefire-reports for the individual test results.
[ERROR] -> [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/MojoFailureException


 

看了一下主要错误就是这一句:Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project

明显就是plugins这个执行不了,

网上找了好几个办法都搞不定,发现为一个解决办法就是更改pom.xml文件

在build里面增加如下代码:(其中这段<plugins></plugins>中间是新增的)

<build>
  <resources>
  			<resource>
  				<directory>src/main/java</directory>
  				<includes>
  					<include>**/*.xml</include>
  				</includes>
  				<filtering>true</filtering>
  			</resource>
  			<resource>
  				<directory>src/main/resources</directory>
  				<includes>
  					<include>**/*.xml</include>
  					<include>**/*.properties</include>
  				</includes>
  				<filtering>true</filtering>
  			</resource>
  </resources>
  <plugins>
     <plugin>  
        <groupId>org.apache.maven.plugins</groupId>  
        <artifactId>maven-surefire-plugin</artifactId>  
        <version>2.4.2</version>  
        <configuration>  
          <skipTests>true</skipTests>  
        </configuration>  
    </plugin>  
  </plugins>
</build>

改完后重跑

结果如下


...
[INFO] Downloaded from aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven-plugin-descriptor/2.0/maven-plugin-descriptor-2.0.jar (33 kB at 21 kB/s)
[INFO] Downloaded from aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven-monitor/2.0/maven-monitor-2.0.jar (7.6 kB at 4.6 kB/s)
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ oa-organ ---
[INFO] Building jar: E:\Develop\eclipse\workspace\oa-organ\target\oa-organ-1.0.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  10.065 s
[INFO] Finished at: 2021-11-27T21:43:13+08:00
[INFO] ------------------------------------------------------------------------

打包成功!

每日学一点Java,争取年底Java能达到初级水平

scr屏幕保护程序来自windowsXP操作系统的屏幕保护程序26个(全部正常使用),其中有17个兼容windows10。windows7/8/8.1/2008/2012待测试。。+热带鱼屏保 SN在文件“+热带鱼屏保 SN.txt“中。使用方法:把scr格式的文件拷贝到windows系统的windows\system32中即可,然后就可以在”桌面>设置>屏幕保护程序”中找到,windows10在任务栏搜索“屏幕保护”就找到屏幕保护程序设置。-------------------------兼容windows10的屏幕保护程序17个:+Flurry-eng(对显卡要求很高).scr+Images of Ireland.scr+Kaleidomorph变换曲线【colour】.scr+logon(windows XP).scr+Particle Fire(流星火焰).scr+Skyrocket(OpenGL,星夜焰火-eng).scr+贝塞尔曲线.scr+单线条(飞舞变化,无设置).scr+多线条(彩色随机变化,无设置).scr+飞越星空.scr+肥皂泡泡(无设置).scr+三维飞行物(3Dwindows徽标).scr+三维管道(OpenGL).scr+三维花盒.scr+三维迷宫(OpenGL).scr+璇彩泡泡.scr+Matrix(矩阵世界3D屏保).scr-----------------------------只用于windowsXP的屏幕保护程序:+3D文字.scr+aurora欧若拉(极光).scr+The Lost Watch 3D Screensaver.scr+XPize.scr+变换线.scr+夜光时钟.SCR+滚动字幕(输入文字).scr+热带鱼屏保 SN.txt+热带鱼屏保.scr+自定义图片屏保.scr-------------------------windows10默认屏保:3D文字变换线彩带空白气泡照片windows光盘安装文件下载、迅雷子帐号共享请加QQ群221906427-->软件硬件学习交流关键字:scr 屏保 屏幕保护程序 xp16:20 2021/10/12
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值