【问题解决】mvn deploy出现401错误
程序员文章站
2022-04-22 19:05:01
...
mvn deploy出现401错误
问题
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on p
roject panda-config: Failed to deploy artifacts: Could not transfer artifact top.alanlee:panda-config:jar:1.0.
0-20200223.035607-1 from/to nexus-snapshots (http://xxx.xxx.245.65:8081/repository/maven-snapshots/): Failed t
o transfer file http://xxx.xxx.245.65:8081/repository/maven-snapshots/top/alanlee/panda-config/1.0.0-SNAPSHOT/
panda-config-1.0.0-20200223.035607-1.jar with status code 401 -> [Help 1]
原因
一般报401这个错,是因为没有权限,没权限的话,大部分都是因为密码错了导致,或者这个账号本身就没有传jar的权限,一般是maven目录conf的setting.xml里没有配置认证,查看maven的config路径下的settings.xml,查看是否设置了用户名和密码。
解决
在.m2/settings.xml中的server节点下设置用户名和密码。
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>密码</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>密码</password>
</server>
在pom.xml文件中添加
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Nexus Release Repository</name>
<url>http://ip:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://ip:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
重新执行mvn deploy
上一篇: Layui 时间控件 闪退问题解决