如何发布代码到maven中心仓库
deploy to sonatype
参考文章
https://blog.csdn.net/xuefu_78/article/details/52494698
https://blog.csdn.net/shelldon/article/details/54291474
步驟
申请sonatype账号
申请账号的地址在这里: https://issues.sonatype.org/secure/Signup!default.jspa
申请完成之后,我们需要提供相应的项目信息,地址在这里:https://issues.sonatype.org/secure/CreateIssue.jspa?issuetype=21&pid=10134
填写group Id,需要按要求填写
创建之后,等待审核
审核通过后
在收到邮件告知后,就可以上传包了
修改setting.xml,添加server项,录入账号密码
<server>
<id>nexus-releases</id>
<username>xx</username>
<password>xxxxx</password>
nexus-snapshots
xx
xxxxx
修改pom.xml
譬如:https://github.com/jianliu/l-poi-excel/blob/master/pom.xml
需要注意的是,parent需要填写
还需要name\url\description\licenses\scm\developers
添加相应的插件 compire\javadoc\releases
添加部署的repository\snapshotRepository
GPG秘钥生成
需要先下载gpg软件windows版本 https://gpg4win.org/download.html
按提示操作过程中,需要自己写一个key,在mvn clean deploy 录入对应的key来验证
gpg的作用是生成公钥,用于加密相关jar包
C:\Users\xx>gpg --gen-key
gpg (GnuPG) 2.2.8; Copyright (C) 2018 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Note: Use "gpg --full-generate-key" for a full featured key generation dialog.
GnuPG needs to construct a user ID to identify your key.
Real name: xxx
Email address: xxx@163.com
You selected this USER-ID:
"xxxxxx@163.com"
Change (N)ame, (E)mail, or (O)kay/(Q)uit? O
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
gpg: key A4396BB5BC1F15DD marked as ultimately trusted
gpg: directory 'C:/Users/cdliujian1/AppData/Roaming/gnupg/openpgp-revocs.d' created
gpg: revocation certificate stored as 'C:/Users/cdliujian1/AppData/Roaming/gnupg/openpgp-revocs.d\279A2AE668EA9A4E34CBE490A4396BB5BC1F15DD.rev'
public and secret key created and signed.
pub rsa2048 2018-08-21 [SC] [expires: 2020-08-20]
279A2AE668EA9A4E34CBE490A4396BB5BC1F15DD
uid xxxxx@163.com
sub rsa2048 2018-08-21 [E] [expires: 2020-08-20]
C:\Users\xx>gpg --list-keys
C:/Users/xx/AppData/Roaming/gnupg/pubring.kbx
pub rsa2048 2018-08-21 [SC] [expires: 2020-08-20]
279A2AE668EA9A4E34CBE490A4396BB5BC1F15DD
uid [ultimate] xxxxx@163.com
sub rsa2048 2018-08-21 [E] [expires: 2020-08-20]
C:\Users\xx>gpg --keyserver hkp://pool.sks-keyservers.net --send-keys 279A2AE668EA9A4E34CBE490A4396BB5BC1F15DD
gpg: sending key A4396BB5BC1F15DD to hkp://pool.sks-keyservers.net
C:\Users\xx>gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 279A2AE668EA9A4E34CBE490A4396BB5BC1F15DD
gpg: key A4396BB5BC1F15DD: "xxxxx@163.com" not changed
gpg: Total number processed: 1
gpg: unchanged: 1
C:\Users\xx>
打包、上传
首先将version修改为 1.0-SNAPSHOT 带上SNAPSHOT,表明它是快照版本
执行mvn clean deploy,期间会要求录入生成gpg秘钥时输入的密码,校验成功才会上传, 这时包就上传到远程本地仓库了,但其他人还不能下载
mvn release 插件并非必须的,在第一次发布时,只要符合规范,mvn clean deploy 就已经做完了全部事情
mvn release 主要用于将代码提交到远程仓库中去,并非必须品
执行
mvn release:prepare
mvn release:perform
正式发布
到https://oss.sonatype.org/#stagingRepositories登录,
选择自己的仓库,先CLOSE,再Release
如果是第一次发布,在Issue下告知一下工作人员
过一会就可以再maven中心仓库查看到了
如何发布代码到maven中心仓库的更多相关文章
- maven中心仓库OSSRH使用简介
目录 简介 为什么使用中心仓库 发布到中心仓库前的准备工作 使用OSSRH 使用Sonatype创建ticket 中央仓库中的组件要求 提供Javadoc 和源代码 使用GPG/PGP给文件签名 Me ...
- Maven学习总结(三):修改从Maven中心仓库下载到本地的jar包的默认存储位置
一:修改从Maven中心仓库下载到本地的jar包的默认存储位置 从Maven中心仓库下载到本地的jar包的默认存放在”${user.home}/.m2/repository”中,${user.home ...
- 修改从Maven中心仓库下载到本地的jar包的默认存储位置及远程仓库
从Maven中心仓库下载到本地的jar包的默认存放在”${user.home}/.m2/repository”中,${user.home}表示当前登录系统的用户目录(如"C:\Users\g ...
- 使用CI/CD工具Github Action发布jar到Maven中央仓库
之前发布开源项目Payment Spring Boot到Maven中央仓库我都是手动执行mvn deploy,在CI/CD大行其道的今天使用这种方式有点"原始".于是我一直在寻求一 ...
- Maven中心仓库
当你使用Maven构建一个项目,Maven会检查你的pom.xml文件,找出需要下载的依赖包.首先它会到本地仓库查找所需的文件,如果没找到,就到默认的中心仓库(这是新的http://search.ma ...
- 我把自己的java库发布到了maven中央仓库,从此可以像Jackson、Spring的jar一样使用它了
欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...
- 发布构件到Maven中央仓库
一.注册jira账号 访问如下网址: https://issues.sonatype.org/secure/Signup.jspa 记住邮箱,用户名,密码以备以后使用,一定牢记. 二.创建一个issu ...
- 发布项目到maven中央仓库
https://www.xiaominfo.com/2017/04/25/swagger-bootstrap-ui-issue-maven-central/?tdsourcetag=s_pcqq_ai ...
- Maven发布Release到中心仓库历程记录(无个人域名)
Maven发布Release到中心仓库历程记录(无个人域名) 前言 因为前段时间自己做了一个爬虫项目(地址),自己很希望分享到maven中心仓库上,感觉拥有自己的jar包令我兴奋,便开始了maven发 ...
随机推荐
- chrome插件: yapi 接口TypeScript代码生成器
前言 2020-09-12 天气晴,蓝天白云,微风,甚好. 前端Jser一枚,在公司的电脑前,浏览器打开着yapi的接口文档,那密密麻麻的接口数据,要一个一个的去敲打成为TypeScript的inte ...
- Apache Hudi和Presto的前世今生
一篇由Apache Hudi PMC Bhavani Sudha Saktheeswaran和AWS Presto团队工程师Brandon Scheller分享Apache Hudi和Presto集成 ...
- msf学习笔记
metasploit frame 这是一个渗透测试框架,围绕这个框架,我们就可以完成最终的目标,即渗透测试. 渗透测试者困扰:需要掌握数百个工具,上千条命令参数,很难记住. 新出现的漏洞PoC/EXP ...
- (一)jenkins+git+docker
目录 一.发布流程设计 1.工作流程 2.环境规划如下 二.部署Git仓库 1.创建Git用户并设置密码 2.创建仓库 3.免密访问 4.在jenkins那台机上做ssh认证 三.准备Jenkins环 ...
- Android小部件Widget开发过程中的坑和总结
@ 目录 概述 官方参考 效果图 AndroidManifest.xml Receiver Service Options res/xml/ widget_desktop_options.xml 常用 ...
- throw throws try catch finally return
throw throw 语句用于抛出异常,例如 throw new EOFException(). throws 当使用throw 语句抛出checked 异常后,可以不用捕获异常并处理,而是使用 ...
- springmvc与mybatis整合时 java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required 异常
今天在整合springmvc与mybatis时,启动服务器遇到这样一个问题, by: java.lang.IllegalArgumentException: Property 'sqlSessionF ...
- 编程体系结构(05):Java多线程并发
本文源码:GitHub·点这里 || GitEE·点这里 一.多线程导图 二.多线程基础 1.基础概念 线程是操作系统能够进行运算调度的最小单位,包含在进程之中,是进程中的实际运作单位.一条线程指的是 ...
- Clover 引导 Windows 及 Linux 双系统
Clover 引导 Windows 及 Linux 双系统UEFI cnblogs @ Orcim 此 文比较详细地介绍了通过修改 Clover 的配置文件,添加 Clover 启动项的方法(添加 ...
- phpstorm中配置使用svn详细步骤
一.搭建SVN环境 1.下载VisualSVN Sever.下载地址:https://www.visualsvn.com/server/download/ 2.安装VisualSVN Server. ...