手撸一个Spring Boot Starter并上传到Maven中央仓库

网友投稿 331 2022-07-28


目录打包上传到中央仓库第一步 在issues.sonatype.org注册一个账号第二步 在issues.sonatype.org提交Issue第三步 配置Maven Setting.xml第四步 配置项目的pom.xml第五步 安装和配置GPG第六步 项目打包上传第七步 处理验证问题 我1.0.1版本发布错了,有办法修改或者删除吗?

先手撸一个Spring Boot Starter

准备搞个项目,包含以下几个功能后边还会加新功能。

配置项加密(已实现)服务调用链数据脱敏…

我的项目地址:https://github.com/lakernote/laker(求star,看能不能混个免费的Idea license)

代码很简单就几行,有兴趣的自己看下哈。

GitHub太卡了,这个就是个尝试,我后边会切到Gitee。

例如原始配置项内容为:

laker:

password: laker11111111111111111

密码是明文的不安全,我们用AES对称加密,假设我们的秘钥为:1234567890123456, 把上面的内容换为加密后字符串,以enc:开头。

laker:

password: enc:25d778c22331899a1f79eab82a1d930b9abc4633fb948387c764e5f1f9e5bd3f

项目引入依赖

io.github.lakernote

laker-spring-boot-starter

1.0.2

项目启动时在命令行加入秘钥

-Denc.key=A string of 16 characters

例如 -Denc.key=1234567890123456

项目运行后实际得到的就是 laker.password:laker11111111111111111

现在我们来打包上传到中央仓库,供其他小伙伴使用吧。

打包上传到中央仓库

步骤很简单,人人都能搞,不要慌。申请时间为2022年5月份。

我的项目地址:https://github.com/lakernote/laker(求star,看能不能混个免费的Idea license)

io.github.lakernote

laker-spring-boot-starter

1.0.2

GitHub太卡了,这个就是个尝试,我后边会切到Gitee。

已经上传到中央仓库,大家可以体验使用。可以在https://search.maven.org/search查询。

第一步 在issues.sonatype.org注册一个账号

地址如下:https://issues.sonatype.org

要记录下自己的用户名和密码,后边要用的。

密码要求如下:

密码必须至少有 12 个字符。密码必须至少包含 1 个大写字符。密码必须至少包含 1 个特殊字符,例如 &、%、™ 或 É。密码必须包含至少 3 种不同的字符,例如大写字母、小写字母、数字和标点符号。密码不得与用户名或电子邮件地址相似。

第二步 在issues.sonatype.org提交Issue

注意与国外时差问题,晚上干,基本秒回。当Issue的Status变为RESOLVED后,就可以进行下一步操作了。

项目:看图片红色部分问题类型:看图片红色部分概要: 说下你项目干啥的GroupId: com.github.* 现在不能用了,改为 io.github.lakernoteProjectURL: 看图片红色部分,填写项目地址SCMURL: 看图片红色部分,填写git地址其他使用默认即可。

注意:你填写的GroupId要等于你pom中的io.github.lakernote。

填写完毕后,点击提交,然后会有人审核让你在GitHub上建立个项目以用于证明是你的项目。

第三步 配置Maven Setting.xml

https://central.sonatype.org/publish/publish-maven/#distribution-management-and-authentication

ossrh

your-jira-id

your-jira-pwd

注意:server的id元素值要与第四步即下面的snapshotRepository的id元素值和repository的id元素值相同。

你不要改就行,使用默认的,把username和password改为第一步你自己的jira用户名和密码。

第四步 配置项目的pom.xml

https://central.sonatype.org/publish/requirements/#license-information

整个pom你不想看也可以,直接复制走傻瓜式用就完事了。

ossrh

https://s01.oss.sonatype.org/content/repositories/snapshots

ossrh

https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/

javadoc、源附件、GPG 签名组件

org.apache.maven.plugins

maven-source-plugin

2.2.1

attach-sources

jar-no-fork

org.apache.maven.plugins

maven-javadoc-plugin

2.9.1

-Xdoclint:none

attach-javadocs

jar

org.apache.maven.plugins

maven-gpg-plugin

1.5

sign-artifacts

verify

sign

项目名称、描述和 URl

Example Application

A application used as an example on how to set up pushing

its components to the Central Repository.

http://example.com/example-application

开源协议

The Apache License, Version 2.0

http://apache.org/licenses/LICENSE-2.0.txt

开发者信息

laker

935009066@qq.com

https://laker.blog.csdn.net

项目信息

scm:git:git://github.com/simpligility/ossrh-demo.git

scm:git:ssh://github.com:simpligility/ossrh-demo.git

http://github.com/simpligility/ossrh-demo/tree/master

整体示例 https://github.com/lakernote/laker/blob/main/pom.xml

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

io.github.lakernote

laker

pom

1.0.2

...

laker-encrypt

laker-spring-boot-starter

laker-spring-boot-starter-test

laker

A collection of tools based on Spring Boot

https://github.com/lakernote/laker

The Apache License, Version 2.0

http://apache.org/licenses/LICENSE-2.0.txt

laker

935009066@qq.com

https://laker.blog.csdn.net

scm:git:git://github.com/lakernote/laker.git

scm:git:ssh://github.com:lakernote/laker.git

http://github.com/lakernote/laker/tree/master

org.apache.maven.plugins

maven-source-plugin

2.2.1

attach-sources

jar-no-fork

org.apache.maven.plugins

maven-javadoc-plugin

2.9.1

-Xdoclint:none

attach-javadocs

jar

org.apache.maven.plugins

maven-gpg-plugin

1.5

sign-artifacts

verify

sign

ossrh

https://s01.oss.sonatype.org/content/repositories/snapshots

ossrh

https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

io.github.lakernote

laker

pom

1.0.2

...

laker-encrypt

laker-spring-boot-starter

laker-spring-boot-starter-test

laker

A collection of tools based on Spring Boot

https://github.com/lakernote/laker

The Apache License, Version 2.0

http://apache.org/licenses/LICENSE-2.0.txt

laker

935009066@qq.com

https://laker.blog.csdn.net

scm:git:git://github.com/lakernote/laker.git

scm:git:ssh://github.com:lakernote/laker.git

http://github.com/lakernote/laker/tree/master

org.apache.maven.plugins

maven-source-plugin

2.2.1

attach-sources

jar-no-fork

org.apache.maven.plugins

maven-javadoc-plugin

2.9.1

-Xdoclint:none

attach-javadocs

jar

org.apache.maven.plugins

maven-gpg-plugin

1.5

sign-artifacts

verify

sign

ossrh

https://s01.oss.sonatype.org/content/repositories/snapshots

ossrh

https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/

第五步 安装和配置GPG

发布到Maven仓库中的所有文件都要使用GPG签名,以保障完整性。因此,我们需要在本地安装并配置GPG。

Windows下载地址:https://gpg4win.org/

1.文件 - 新建密钥对

2.在证书列表,右键点击在服务器上发布

第六步 项目打包上传

首先:执行命令 mvn clean deploy或者在idea点击deploy按钮

然后:登陆https://s01.oss.sonatype.org/ 去处理你刚刚deploy的jar包

选择taging Repositories选择你的项目点击close点击release

第七步 处理验证

上面执行完成后,我们去https://repo1.maven.org/maven2/ 中可以搜索,大概10-30分钟后可以搜索到。这个时候我们就可以在项目中引用了。

但是同步到中央仓库搜索可能要4个小时左右。

中央仓库地址: https://search.maven.org/。

例如我的:https://repo1.maven.org/maven2/io/github/lakernote/laker-spring-boot-starter/

问题 我1.0.1版本发布错了,有办法修改或者删除吗?

官方答复如下:Sonatype 政策禁止在工件发布后对其进行移除或任何其他修改。即无法覆盖现有版本。必须发布一个新的更正版本。


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:SpringBoot整合Minio实现上传文件的完整步骤记录
下一篇:guava中Multimap、HashMultimap用法小结(multimap)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~