原文链接
前言
如果有在Maven
仓库上传过包的小伙伴,最近应该收到了中央仓库的邮件,提示需要使用用户令牌进行身份验证,而不是原来的账号的密码:
Dear Maven Central publisher,
We are making changes to the OSSRH authentication backend. For most users this should be a transparent process, and you should be able to continue to use your existing username and password to connect the Nexus UI. In case you need to update your password, please follow our documentation.
To configure a publisher’s plugin authentication you would need to update your plugin settings to use a user token instead of the Nexus UI username and password login.
For more information about publishing to legacy OSSRH please consult our documentation at https://central.sonatype.org/register/legacy/
Thank you,
The Central Team
如果我们未收到或者忽略这条邮件,则会在上传maven
包的时候,得到401 Content access is protected by token
的错误
解决方案
使用新的验证方式即可,登录Maven Centarl Respository
- 点击右上角用户名,选择
Profile
- 将下拉框设置为
User Token
- 添加生成
Token
- 将提供的
<server>
标签内容复制到本地setting.xml
文件中,替换原有的账号密码的验证方式 - 替换
server::id
为原有值
此时重新发布maven
包即可成功