常见maven异常处理



maven的概述:

Maven是一个项目管理和整合的工具。Maven为开发者提供了一套完整的构建生命周期框架。开发团队基本不用花多少时间就能自动完成工程的基础构建配置,因为Maven使用了一个标准的目录结构和一个默认的构建生命周期。在创建报告、检查、构建和测试自动配置时,Maven可以让开发者的工作变得更简单。

但使用时总会碰到这个那个的异常,maven常见异常总结:

测试代码异常:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on project web_nanchang: There are test failures.
[ERROR]
[ERROR] Please refer to E:\maven\web_nanchang\target\surefire-reports for the individual test results.

解决方法:

这是因为测试代码时遇到错误,它会停止编译。只需要在pom.xml的<project>里添加以下配置,使得测试出错不影响项目的编译。

构件下载异常

[ERROR] Failed to execute goal on project biz_zhuhai: Could not resolve dependencies for project 
biz_zhuhai:biz_zhuhai:jar:0.0.1-SNAPSHOT: Failed to collect dependencies for [com.maywide.ibh:lib345:pom:1.0 (compile)]: Failed to read artifact descriptor for 
com.maywide.ibh:lib345:pom:1.0: Could not transfer artifact 
com.maywide.ibh:lib345:pom:1.0 from/to releases (
http://localhost:9888/nexus-2.0.3/content/repositories/releases): Connection to 
http://localhost:9888 refused: Connection refused: connect -> [Help 1]

解决方法:

这是配置的url有错误或者是私服没有配好,导致构件下载时出错。如果没有jar包需要在私服里下载,可以不配置私服的,也就是可以把setting.xml的profiles里的东西全部删除的。


其他异常

NO1:异常1

[ERROR] Failed to execute goal org.codehaus.cargo:cargo-
maven2-plugin:1.0.6:start (start-container) on project myproject: Execution start-container of goal 
org.codehaus.cargo:cargo-maven2-plugin:1.0.6:start failed: Error while expanding 
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\cargo\installs\apache-tomcat-6.0.29.zip
[ERROR] java.io.IOException: Negative seek offset

解决方法:

自己下载“apache-tomcat-6.0.29.zip”,将下载好的文件拷贝到指定文件夹“C:\Documents and Settings\Administrator\Local Settings\Temp\cargo\installs”下。


NO2:异常2

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war 
(default-war) on project web_nanchang: Error assembling WAR: 
webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]

解决方法:

maven的web项目默认的webroot是在src\main\webapp。如果在此目录下找不到web.xml就抛出以上的异常。解决方法在pom.xml加入以下的配置。红色字体改成你网站的根目录。







猜你喜欢

转载自blog.csdn.net/weixin_41648325/article/details/80045495