Java-Maven-解决maven deploy时报 401 Reason Phrase Unauthorized 错误 环境 Java jdk 1.8Maven 3.3.9 引言 项目需要打成ja
项目需要打成jar包上传到私服,供其它项目引用。此时需要执行 mvn clean deploy 命令,执行过程中报 401 错误。
执行命令:mvn clean deploy -DskipTests
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project xxxxx: Failed to deploy artifacts: Could not transfer artifact com.xxxxx:xxxxx:jar:spring-1.0.10-20210812.035258-1 from/to nexus-snapshots (http://xxxx.com/nexus/content/repositories/snapshots): Failed to transfer file: http://xxxx.com/nexus/content/repositories/snapshots/com/.../spring-1.0.10-SNAPSHOT/xxxxx-spring-1.0.10-20210812.035258-1.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/MojoExecutionExceptionPS D:\...\xxxxx> mvn clean deploy -DskipTests
nexus-snapshots deployment 123456 ...
[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ mytest ---Downloading: http://dev.xxx.com/nexus/content/repositories/snapshots/com/xxxx/spring-1.0.10-SNAPSHOT/maven-metadata.xmlUploading: http://dev.xxx.com/nexus/content/repositories/snapshots/com/xxxx/spring-1.0.10-SNAPSHOT/mytest-spring-1.0.10-20210812.035231-1.jarUploaded: http://dev.xxx.com/nexus/content/repositories/snapshots/com/xxxx/spring-1.0.10-SNAPSHOT/mytest-spring-1.0.10-20210812.035231-1.jar (127643 KB at 13522.8 KB/sec)Uploading: http://dev.xxx.com/nexus/content/repositories/snapshots/com/xxxx/spring-1.0.10-SNAPSHOT/mytest-spring-1.0.10-20210812.035231-1.pomUploaded: http://dev.xxx.com/nexus/content/repositories/snapshots/com/xxxx/spring-1.0.10-SNAPSHOT/mytest-spring-1.0.10-20210812.035231-1.pom (7 KB at 53.9 KB/sec)Downloading: http://dev.xxx.com/nexus/content/repositories/snapshots/com/xxxx/maven-metadata.xmlUploading: http://dev.xxx.com/nexus/content/repositories/snapshots/com/xxxx/spring-1.0.10-SNAPSHOT/maven-metadata.xmlUploaded: http://dev.xxx.com/nexus/content/repositories/snapshots/com/xxxx/spring-1.0.10-SNAPSHOT/maven-metadata.xml (803 B at 8.2 KB/sec)Uploading: http://dev.xxx.com/nexus/content/repositories/snapshots/com/xxxx/maven-metadata.xmlUploaded: http://dev.xxx.com/nexus/content/repositories/snapshots/com/xxxx/maven-metadata.xml (297 B at 2.5 KB/sec)Uploading: http://dev.xxx.com/nexus/content/repositories/snapshots/com/xxxx/spring-1.0.10-SNAPSHOT/mytest-spring-1.0.10-20210812.035231-1-sdk.jarUploaded: http://dev.xxx.com/nexus/content/repositories/snapshots/com/xxxx/spring-1.0.10-SNAPSHOT/mytest-spring-1.0.10-20210812.035231-1-sdk.jar (602 KB at 3039.0 KB/sec)Uploading: http://dev.xxx.com/nexus/content/repositories/snapshots/com/xxxx/spring-1.0.10-SNAPSHOT/maven-metadata.xmlUploaded: http://dev.xxx.com/nexus/content/repositories/snapshots/com/xxxx/spring-1.0.10-SNAPSHOT/maven-metadata.xml (1021 B at 8.4 KB/sec)[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 37.694 s[INFO] Finished at: 2023-08-22T11:56:51+08:00[INFO] Final Memory: 73M/974M[INFO] ------------------------------------------------------------------------
当我们使用package来打包项目的时候,就会在我们的项目目录下生成一个target文件夹。
如果是WEB项目比如mvc项目就会在该文件夹下生成一个war包,放在服务器中的Tomcat/webapps目录里即可运行。
如果是Java项目的话就会在该文件夹下生成一个jar包,放在服务器中指定目录下使用"java -jar jar包名"命令运行。
一般我们服务器部署服务都是使用package方式打包项目。
使用install方式就是将项目转换成为maven依赖存放在本地maven仓库中。
就比如我的Spring Boot项目执行mvn install 命令后,将把jar存在我本地maven仓库中。
比如我自己配置的maven路径是:D:\java\maven\repository… 。
一般是多个项目中,例如a项目中使用了b项目的一些方法需要添加b项目作为依赖,此时就需要将b项目使用install方式打包到本地[maven]仓库中,以此来给a项目依赖导入调用。
deploy与install的主要区别就是install是将项目jar包放在本地仓库,而deploy是放在私服仓库。
在本地的pom文件配置好私服仓库的信息之后,执行deploy命令,可以将maven所打的jar包上传到远程的repository,便于其他开发者和工程共享。
执行maven deploy命令成功之后,登录私服进行查询,即可看到对应的jar包。
直接运行上面的命令,默认会执行单元测试代码,跳过单元测试使用如下命令:
来源地址:https://blog.csdn.net/xxj_jing/article/details/132430681
--结束END--
本文标题: Java-Maven-解决maven deploy时报 401 Reason Phrase Unauthorized 错误
本文链接: https://lsjlt.com/news/423717.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-04-01
2024-04-03
2024-04-03
2024-01-21
2024-01-21
2024-01-21
2024-01-21
2023-12-23
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0