[前言]
之前写过若干java开发时简化操作或者是拓展功能的工具包,因为懒好久没更新了。最近因为个别项目里面使用时出现应用场景不太够就更新了一波。本打算立刻发布到maven的中心库中以便引入,突然发现发不上去了!于是有了以下调查内容。

背景

发布时出现401错误

Remote staging finished with a failure: Failed to deploy artifacts: Could not transfer artifact cn.allbs:allbs-influx:jar:javadoc:2.1.0 from/to sonatype-nexus-snapshots (s01.oss.sonatype.org:443/service/loc…): status code: 401, reason phrase: Content access is protected by token (401)

失败场景
image.png

登录仓库查看

仓库中缺少很多包的信息,只有很久没更新过的包残存在上面。
登录仓库

管理端查看

管理端
查了一下自己仓库,发现包其实是上传上来了,但是关闭并发布是不起效果的。考虑了一下可能又换仓库了,想起官方访问页面之前是变了样式得,也和这种可能性相和。这样得话只能去官方找资料查看了。
查记录

开始解决

官网上的说明文档

链接如下:
https://central.sonatype.org/faq/what-is-different-between-central-portal-and-legacy-ossrh/

官方文档

大致可以看出旧版和新版并不兼容,同时旧版的命名空间并不能带入到新版之中,如果要迁移必须写邮件申请。

开始转移namespace

注意这些操作全是基于你在旧版上注册过!以下邮件的红色内容需要替换为你自己实际信息,不要照抄。
申请转移的错误邮件

  • 主题:Request for Namespace Migration to OSSRH
  • 邮件接收方:central-support@sonatype.com
  • 内容参考:
Dear Central Support Team,

I am writing to request the migration of my namespace from OSSRH to the Central Portal. Below are the details of my account and the namespace I wish to migrate:

- **Account Information:**
    
    - Username: [你的旧版账号]
    - Email: [账号绑定的邮箱]
- **Namespace(s) to Migrate:**
    
    - 你的namespace

The reason for this migration request is to facilitate the version iteration and maintenance of our existing functionality packages. We believe that migrating to OSSRH's Central Portal will provide better management capabilities and access to new features that will enhance our development and deployment processes.

I appreciate your assistance with this request and look forward to your response. Please let me know if any additional information is required.

Thank you.

Best regards,  
[你的姓名]  
[你的联系方式]

没几分钟就能收到对方的回复邮件,其实下面这种图是第一次我发邮件内容不清晰的后回复的图片😂。
ps:我这篇文章最开始发在掘金的,其实邮件内容是错的,有其他公众号照抄其实也错了😂。

申请邮件未说清楚后回复的邮件

内容需要更正一下发送可以抄上面英文邮件内容,不要抄上面图片内容。得到的结果如下:

回复的邮件

新版maven central中的记录:

maven central

修改deploy至新库

首先是获取userToken

新的maven公共库和以前的方式不同,deploy需要发布的用户名和token

修改maven的setting.xml

java的pom.xml中的修改

主要是两处地方
一是:
image.png

第二处:
image.png

执行deploy看看效果

能推入库中说明以上配置已经生效了,但是因为namespace还未从旧版移过来所以发布失败了。下面只需要安心等待即可。
maven deploy

deploy效果

消息通知