java面试题网站:www.javaoffers.com
上传命令:
mvn deploy:deploy-file -DgroupId=主包名 -DartifactId=项目名 -Dversion=版本号 -Dpackaging=jar -Dfile=要上传到私服的jar包 -Durl=私服地址 -DrepositoryId=仓库id(在setting.xml中配置)
私服地址
http://urcs.feinno.com:5260/repository/maven-releases
私服密码
username/password
案例如下:
cmj@cmj-Inspiron-7590:~/nohup$ mvn deploy:deploy-file -DgroupId=org.helium.stack.ngap -DartifactId=amf-ngap-test -Dversion=1.0.0 -Dpackaging=jar -Dfile=5gc.stack.ngap.test.jar -Durl=http://urcs.feinno.com:5260/repository/maven-releases -DrepositoryId=releases
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy-file (default-cli) @ standalone-pom ---
Uploading to releases: http://urcs.feinno.com:5260/repository/maven-releases/org/helium/stack/ngap/amf-ngap-test/1.0.0/amf-ngap-test-1.0.0.jar
Uploading to releases: http://urcs.feinno.com:5260/repository/maven-releases/org/helium/stack/ngap/amf-ngap-test/1.0.0/amf-ngap-test-1.0.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.720 s
[INFO] Finished at: 2020-09-14T16:22:30+08:00
[INFO] ------------------------------------------------------------------------
[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 org.helium.stack.ngap:amf-ngap-test:jar:1.0.0 from/to releases (http://urcs.feinno.com:5260/repository/maven-releases): Transfer failed for http://urcs.feinno.com:5260/repository/maven-releases/org/helium/stack/ngap/amf-ngap-test/1.0.0/amf-ngap-test-1.0.0.jar **401 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
解决报错,需要添加账户和密码在setting,xml文件中
<server>
<id>releases</id> <!--要和mvn命令中的 -DrepositoryId=releases 一致-->
<username>username</username>
<password>password</password>
</server>
然后再次执行命令
cmj@cmj-Inspiron-7590:~/nohup$ mvn deploy:deploy-file -DgroupId=org.helium.stack.ngap -DartifactId=amf-ngap-test -Dversion=1.0.0 -Dpackaging=jar -Dfile=5gc.stack.ngap.test.jar -Durl=http://urcs.feinno.com:5260/repository/maven-releases -DrepositoryId=releases
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy-file (default-cli) @ standalone-pom ---
Uploading to releases: http://urcs.feinno.com:5260/repository/maven-releases/org/helium/stack/ngap/amf-ngap-test/1.0.0/amf-ngap-test-1.0.0.jar
Uploaded to releases: http://urcs.feinno.com:5260/repository/maven-releases/org/helium/stack/ngap/amf-ngap-test/1.0.0/amf-ngap-test-1.0.0.jar (50 MB at 9.0 MB/s)
Uploading to releases: http://urcs.feinno.com:5260/repository/maven-releases/org/helium/stack/ngap/amf-ngap-test/1.0.0/amf-ngap-test-1.0.0.pom
Uploaded to releases: http://urcs.feinno.com:5260/repository/maven-releases/org/helium/stack/ngap/amf-ngap-test/1.0.0/amf-ngap-test-1.0.0.pom (408 B at 990 B/s)
Downloading from releases: http://urcs.feinno.com:5260/repository/maven-releases/org/helium/stack/ngap/amf-ngap-test/maven-metadata.xml
Uploading to releases: http://urcs.feinno.com:5260/repository/maven-releases/org/helium/stack/ngap/amf-ngap-test/maven-metadata.xml
Uploaded to releases: http://urcs.feinno.com:5260/repository/maven-releases/org/helium/stack/ngap/amf-ngap-test/maven-metadata.xml (314 B at 690 B/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.425 s
[INFO] Finished at: 2020-09-14T16:29:29+08:00
[INFO] ------------------------------------------------------------------------
下载刚才上传的jar包
mvn dependency:get -DremoteRepositories=http://urcs.feinno.com:5260/repository/maven-releases -DgroupId=org.helium.stack.ngap -DartifactId=amf-ngap-test -Dversion=1.0.0
cd ~/.m2/repository/org/helium/stack/ngap/amf-ngap-test/1.0.0 查看