目录

1. sonatype网站相关

1.1  注册sonatype网站账号

1.2  登录后,新建问题

3. 配置maven--setting.xml

4. 配置maven--pom.xml

4.1 添加个人信息

4.2 添加开源版权信息

4.3 添加scm信息

4.4 添加插件

4.4 添加build

5. 下载GPG加密

5.1 安装Gpg4Win

5.2 创建密钥对

5.3 验证版本

5.4 查看已生成的公私要信息

5.5 发送公钥信息到ubuntu.com服务器

5.6 查询是否发送成功

5.7 发送公钥异常:gpg: keyserver send failed: Unknown error

6. 上传到maven中央仓库

6.1 命令行:

6.2 idea 执行

7 发布结果


1. sonatype网站相关

1.1  注册sonatype网站账号

Sign up for Jira - Sonatype JIRA

1.2  登录后,新建问题

新建后,等待工作人员评论

如果评论这样的话,在github上创建一个对应空项目。

这样就是认证通过了,可以上传项目到中央仓库。

3. 配置maven--setting.xml

在 <servers>标签下添加

<server><id>ossrh</id><username>你sonatype账号</username><password>sonatype 密码</password></server>

4. 配置maven--pom.xml

4.1 添加个人信息

<name>object-comparator</name>
<description>Java object property value comparator</description>
<url>https://github.com/jinchunzhao/object-comparator</url><developers><developer><id>jinchunzhao</id><name>jinchunzhao</name><email>15136708953@163.com</email></developer>
</developers>

4.2 添加开源版权信息

根据项目的开源协议

<licenses><license><name>The Apache Software License, Version 2.0</name><url>http://www.apache.org/licenses/LICENSE-2.0.txt</url></license></licenses>

4.3 添加scm信息

<scm><connection>https://github.com/jinchunzhao/object-comparator.git</connection><url>https://github.com/jinchunzhao/object-comparator</url></scm>

4.4 添加插件

distributionManagement 下面的id必须要和你 maven settings.xml里面的id配置的一模一样

<profiles><profile><id>release</id><activation><activeByDefault>true</activeByDefault></activation><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-source-plugin</artifactId><version>2.2.1</version><executions><execution><phase>package</phase><goals><goal>jar-no-fork</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-javadoc-plugin</artifactId><version>2.9.1</version><configuration><show>private</show><nohelp>true</nohelp><charset>UTF-8</charset><encoding>UTF-8</encoding><docencoding>UTF-8</docencoding><additionalparam>-Xdoclint:none</additionalparam></configuration><executions><execution><phase>package</phase><goals><goal>jar</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-gpg-plugin</artifactId><version>1.6</version><executions><execution><phase>verify</phase><goals><goal>sign</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.7.0</version><configuration><source>1.8</source><target>1.8</target></configuration></plugin><!--Release --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-release-plugin</artifactId><version>2.5.1</version></plugin><plugin><artifactId>maven-deploy-plugin</artifactId><version>2.8.2</version><executions><execution><id>default-deploy</id><phase>deploy</phase><goals><goal>deploy</goal></goals></execution></executions></plugin><plugin><groupId>org.sonatype.plugins</groupId><artifactId>nexus-staging-maven-plugin</artifactId><version>1.6.7</version><extensions>true</extensions><configuration><serverId>ossrh</serverId><nexusUrl>https://s01.oss.sonatype.org/</nexusUrl><autoReleaseAfterClose>true</autoReleaseAfterClose></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-scm-plugin</artifactId><version>1.8.1</version></plugin></plugins></build><!-- 这里配置的ossrh要与settings.xml的一致,不然发布会出错 --><distributionManagement><snapshotRepository><id>ossrh</id><name>Sonatype Nexus Snapshots</name><url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url></snapshotRepository><repository><id>ossrh</id><name>Nexus Release Repository</name><url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url></repository></distributionManagement></profile></profiles>

4.4 添加build

<build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>8</source><target>8</target></configuration></plugin></plugins></build>

5. 下载GPG加密

Gpg4win - Download Gpg4win

5.1 安装Gpg4Win

傻瓜式安装

5.2 创建密钥对

5.3 验证版本

ggp --version

5.4 查看已生成的公私要信息

gpg --list-keys

5.5 发送公钥信息到ubuntu.com服务器

gpg --keyserver hkp://keyserver.ubuntu.com:11371 --send-keys 刚刚生成的公钥 

5.6 查询是否发送成功

gpg --keyserver hkp://keyserver.ubuntu.com:11371 --recv-keys 刚刚发送的公钥 

5.7 发送公钥异常:gpg: keyserver send failed: Unknown error

适用我的解决办法是:

执行下面两个命令

gpgconf --kill dirmngrdirmngr --debug-all --daemon --standard-resolver

在另一个终端上运行推送公钥命令就可以了。

6. 上传到maven中央仓库

6.1 命令行:

mvn clean deploy -P release -Dmaven.test.skip=true
# 这里的 -P release与pom.xml中的标签一致
<profile><id>release</id>
</profile>

6.2 idea 执行

执行成功

7 发布结果

表明已经发布成功了。

这样就可以到 Maven Central Repository Search 去查刚刚发布的项目,如果没有查到也关系,同步需要一段时间。

Maven发布自己项目到maven中央仓库相关推荐

  1. Maven发布web项目到tomcat

    在java开发中经常要引入很多第三方jar包:然而无论是java web开发还是其他java项目的开发经常会由于缺少依赖包引来一些不必要的异常.常常也是因为这样的原因导致许多简单的缺包和版本问题耗费大 ...

  2. Maven 教程之发布 jar 到私服或中央仓库

    :notebook: 本文已归档到:「blog」 发布 jar 包到中央仓库 为了避免重复造轮子,相信每个 Java 程序员都想打造自己的脚手架或工具包(自己定制的往往才是最适合自己的).那么如何将自 ...

  3. Maven - 发布JAR包到Maven远程中央仓库

    声明:经过下面一系列操作之后,以后想发布新版本,只要修改好要升级的版本,然后在 Maven的 Lifecycle 里双击 deploy 即可~ 前言 自使用maven以来,没少使用maven中央仓库中 ...

  4. 使用gradle插件发布项目到nexus中央仓库

    文章目录 简介 Gradle Nexus Publish Plugin历史 插件的使用 Groovy DSL Kotlin DSL 插件背后的故事 总结 简介 Sonatype 提供了一个叫做开源软件 ...

  5. Maven使用技巧001--- 离线更新nexus中央仓库索引的方案

    nexus可以在线更新中央仓库索引,但是更新速度慢,而且很有可能下载的索引不全.下面介绍一种离线更新中央仓库索引的方式,速度快并且可靠. 1.访问http://repo.maven.apache.or ...

  6. 【转】maven Failure to find xxx in 中央仓库

    转自 https://blog.csdn.net/FU250/article/details/84400426 问题描述,本地仓库有该jar包,但是中央仓库没有该包,mvn编译时一直报如右错误:Fai ...

  7. 如何将自己开源的项目发布到maven中央仓库

    关注"Java艺术"一起来充电吧! 如何将开源项目发布到maven中央仓库,让别人通过依赖使用你的开源项目,想必很多朋友都有过这个想法. 去年我就想将自己开源的一个miniexce ...

  8. 我把自己的java库发布到了maven中央仓库,从此可以像Jackson、Spring的jar一样使用它了

    欢迎访问我的GitHub 这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos 关于maven中央仓库 作为一个java程序员,对ma ...

  9. Maven发布封装到中央仓库时候报错:no default secret key: No secret key

    点击上方蓝色"程序猿DD",选择"设为星标" 回复"资源"获取独家整理的学习资料! 今天因为发布swagger-spring-boot-st ...

最新文章

  1. vue获取dom元素注意问题
  2. 进阶学习(4.4) JVM GC Root 判定, 垃圾的判定
  3. Virtualbox虚机无法启动因断电
  4. binlog2sql使用总结
  5. VirtualBox安装win10虚拟机
  6. 文件搜索工具(简单版)
  7. python如何对excel批量加密_用python加密excel工作表
  8. IDEA TODO标签使用
  9. eclipse启动很慢调优
  10. 敏捷开发模式下如何用 PingCode 这类工具进行版本发布管理
  11. InnoDB存储引擎——缓冲池
  12. estimate, underestimate and overestimate
  13. 经验谈|如何处理好产品与开发的关系
  14. position的absolute与fixed共同点与不同点
  15. 全面解决Jenkins离线、安装插件失败
  16. 计算机二级Python 真题(基础题)
  17. 高科路由器有虚拟服务器设置吗,高科(GAOKE)路由器怎么设置无线网络?
  18. Shell脚本编程实践——第3关:使用Shell脚本创建文件目录
  19. PDA提示服务器返回数据为空,三农普PDA数据采集软件常见问题及解决方案
  20. launch计算机上哪个初中,launch是什么意思

热门文章

  1. JDK是什么?JDK包含哪些内容?
  2. char 类型与lpcwstr_C++类型转换 LPWSTR转char*
  3. VUE-cli环境搭建(SHD创新实验室第三次任务环境搭建)
  4. 详解 OpenDAL |Data Infra 研究社第三期
  5. [项目管理-5]:软硬件项目管理 - 项目人力资源管理 (人)
  6. mac如何用python爬网页数据_Mac——利用Python进行网页爬取
  7. 【虫师--系列20】性能测试知多少---性能分析与调优的原理
  8. Loadrunner11使用代理录制脚本
  9. AJAX、异步和同步区别
  10. Linux内存清道夫--OOM Killer