天天看点

Maven常见异常及解决方法

异常1:

[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里的东西全部删除的。

异常2:

[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>里添加以下配置,使得测试出错不影响项目的编译。

异常3:

[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

[error] -> [help 1]

[error] to see the full stack trace of the errors, re-run maven with the -e swit

ch.

[error] re-run maven using the -x switch to enable full debug logging.

[error] for more information about the errors and possible solutions, please rea

d the following articles:

[error] [help 1] ​​http://cwiki.apache.org/confluence/display/maven/pluginexecutio​​

nexception

自己下载“apache-tomcat-6.0.29.zip”,将下载好的文件拷贝到指定文件夹“c:\documents and settings\administrator\local settings\temp\cargo\installs”下。

异常4:

[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]

[error] to see the full stack trace of the errors, re-run maven with the -e switch.

[error] for more information about the errors and possible solutions, please read the following articles:

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

异常5:

eclipse中maven工程缺少maven dependencies

产生这种现象的原因可能是工程对应的开发环境改变,本地maven仓库地址和原来的不一致。其根本原因是maven project的maven选项未开启或启动无效。

为了解决这个问题我们只需要重启dependency management就可以了。

具体步骤:右击 maven project --> macven --> enable dependency management

说明:如果我们原有的工程中的maven处于enable状态下,但是同样没有maven dependencies类库,我们将原有的maven project执行disable dependency management,然后再重启下就行了。