`

Maven 发布自定义jar包到Nexus中

阅读更多
发布命令如下:
mvn deploy:deploy-file -DgroupId=ddd.util -DartifactId=ddd-util -Dversion=1.0 -Dpackaging=jar -Dfile=C:\Users\Administrator\Desktop\dddutil.jar -Durl=http://ip:port/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty

-DgroupId 项目
-DartifactId 模块
-Dversion 版本号
-Dpackaging是打包方式
-Dfile 架包的本地路径
-Durl 是仓库地址。
-DrepositoryId=thirdparty 是你要发布到Nexus中哪个仓库下去。
注意这儿的id是你的nexus中Repositories中对应的库中configuration中的Repository ID。如下图:


发布时报错:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default
-cli) on project standalone-pom: Failed to deploy artifacts: Could not transfer artifact ddb.util:dd
b-util:jar:1.0 from/to thirdparty (http://ip:port/nexus/content/repositories/thirdpa
rty/): Failed to transfer file: http://ip:port/nexus/content/repositories/thirdparty/ddb/
util/ddb-util/1.0/ddb-util-1.0.jar. Return code is: 401, ReasonPhrase:Unauthorized. -> [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 arti
cles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

解决办法
需要在maven中的conf下的setting.xml中添加:
<server>
 <id>thirdparty</id>
 <username>账号</username>
 <password>密码</password>
</server>

这儿id和发布的id一致。
再来一次就发布成功了。
  • 大小: 59.9 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics