上传jar包到Maven仓库

进入 /Users/*****/app/common/service/facade  执行 mvn install 即可在target目录下打出jar包
执行以下命令即可将jar包上传到maven仓库
mvn clean install org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file \
-Durl=http://mvn.**.net/artifactory/content/repositories/xxx-Releases \
-DrepositoryId=devRepo \
-DgroupId=com.xx.xx \
-DartifactId=xx-common-service-facade \
-Dversion=1.0.0.20180316 \
-Dpackaging=jar \
-Dfile=target/xx-common-service-facade-1.0.0.20180316.jar \
-Dsources=target/xx-common-service-facade-1.0.0.20180316-sources.jar
 
上传jar包的过程中有身份验证,如果身份验证不通过会报以下错误
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file (default-cli) on project zappinfo-facade: Failed to deploy artifacts: Could not transfer artifact com.xx.xx:xx-facade:jar:2.0.1.20180314 from/to central (http://mvn.dev.xx.net/artifactory/content/repositories/xx-Releases): Failed to transfer file: http://mvn.dev.xx.net/artifactory/content/repositories/xx-Releases/com/x/zpaas/xx-facade/2.0.1.20180314/xx-facade-2.0.1.20180314.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 articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
 
此时需要在maven的配置文件中添加用户名和密码
 
/Users/xx/program/apache-maven-3.5.2/conf/settings.xml 中配置了maven仓库的用户名密码
  <servers>
     <server>
       <id>devRepo</id>
       <username>xx</username>
       <password>123456</password>
     </server>
</servers>
 

猜你喜欢

转载自umgsai.iteye.com/blog/2413341
今日推荐