Maven Nexus常见错误

来源:互联网 发布:办公室网络兼职 编辑:程序博客网 时间:2024/06/15 18:54

目前碰到以下几种情况

1. pom.xml依赖有误

[ERROR] Failed to execute goal on project dealserver:
Could not resolve dependencies for project com.meituan.service.mobile.prometheus:dealserver:war:0.1-beta:
Failed to collect dependencies at com.meituan.service.mobile.prometheus:deal-common:jar:0.1-beta:
Failed to read artifact descriptor for com.meituan.service.mobile.prometheus:deal-common:jar:0.1-beta:
Failure to find com.meituan.service.mobile:prometheus:pom:1.0-SNAPSHOT in http://maven.sankuai.com/nexus/content/groups/public-snapshots
was cached in the local repository, resolution will not be reattempted until the update interval of nexus-snapshot has elapsed or updates are forced -> [Help 1]

如上,症状为-SNAPSHOT结尾的包不存在public-snapshots中,可能为pom.xml写错(发布的包依赖的包可能有对-SNAPSHOT有依赖);或者为-SNAPSHOT包还没有上传。

2. 依赖的包上传之前进行发布, 生成.lastUpdated文件导致包上传之后发布也找不到对应依赖

[ERROR] Failed to execute goal on project groupapi:
Could not resolve dependencies for project com.meituan.service.mobile:groupapi:war:1.0:
Failure to find com.meituan.service.mobile.group:groupbase:jar:0.5.01-api in http://maven.sankuai.com/nexus/content/groups/public-snapshots
was cached in the local repository, resolution will not be reattempted until the update interval of nexus-snapshot has elapsed or updates are forced -> [Help 1]

如上,可能的症状为非-SNAPSHOT结尾的包去public-snapshots寻找。查找~/.m2/repository目录下面groupbase是否只有.lastUpdated文件,mvn clean install -U或者删掉.lastUpdated文件可解决。


3.  手工上传jar包失败

# 手工上传jar到maven
mvn -X deploy:deploy-file -DgroupId=com.meituan.service.mobile -DartifactId=groupgeo -Dversion=0.3.6 -Dpackaging=jar -Dfile=/tmp/groupgeo-0.3.6.jar -Durl=http://10.64.12.230:8081/nexus/content/group/public/ -DrepositoryId=meituan-nexus-releases
# 提示如下错误
[ERROR] Failed to transfer file: http://10.64.12.230:8081/nexus/content/groups/public/com/meituan/service/mobile/groupgeo/0.3.6/groupgeo-0.3.6.jar. Return code is: 400
    at org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:368)
    at org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:280)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:811)
    ... 28 more
[ERROR]
[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/MojoExecutionException

 错误原因是Durl不能为group地址,group是仓库的集合,,不能上传jar到group,应该为 meituan-nexus-releases 对应的仓库地址,比如:http://10.64.12.230:8081/nexus/content/repositories/releases/

 

4.  package not exists问题

package com.caucho.hessian.client does not exist

这中情况有可能是上一次发布时正在下载jar包,被用户“中止发布”后该jar包没有下载完整导致的, 登录到发布机上将对应的maven缓存jar包删除即可。


5.  mvn deploy返回400, ReasonPhrase: Bad Request

Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: http://10.64.12.230:8081/nexus/content/repositories/releases/com/meituan/storm/realtime_kpi_analysis/0.0.1_20150519.093924-1/realtime_kpi_analysis-0.0.1_20150519.093924-1.jar. Return code is: 400, ReasonPhrase: Bad Request.

SNAPSHOT jar包不能上传到release仓库或者thirdpary仓库, 只能上传到snapshots仓库,否则会返回400错误。

另外,已经存在的jar包,不能再次上传,否则也会提示400错误。


6.  Nexus删除jar包一定要通过nexus.sankuai.com界面删除

  nexus并不真正删除jar包,会放在trash目录下,这样可以恢复被删除的jar包。

  https://support.sonatype.com/entries/87266057-How-to-restore-a-deleted-component-from-trash-of-a-Maven-repository


7.  mvn deploy返回401

Failed to transfer file:http://nexus.sankuai.com:8081/nexus/content/repositories/snapshots/com/meituan/mtrace/mtrace/1.0.6-tair-SNAPSHOT/mtrace-1.0.6-tair-20150609.074733-1.jar.Return code is: 401 -> [Help 1]
[ERROR]

 401错误是没有权限,一般是账号有问题,请检查 ~/.m2/settings.xml 中的账号是否为deployment, settings.xml要给所有需要上传的repository都配置账号。


原创粉丝点击