提交自己的jar包到Maven官方仓库
做为资深的Java开发者,我们经常通过maven 来引用其它jar包,其实我们自己编写的开源项目仓库也可以打成jar包部署到Maven 官方的私服上去,这也是初级开发与高级开发间的一个鸿沟。话不多说,咱们开始吧:
0、准备开源项目
首先你得有个开源项目,并把代码提交到托管平台。github也好、gitee 也罢,提交代码代码并把仓库设置为开源。
1、创建账号 issues.sonatype.org
创建完账号后登录
2、提交Open Source Project Repository Hosting申请
提交 Community Support - Open Source Project Repository Hosting 申请,此处如果有域名一定绑定域名,没有域名的话可以用github来托管代码。此处要注意格式与步骤0包的名称映射。 io.github.username pom.xml 中的 groupId也得按这种格式来
3、配置pom.xml 和 settings.xml 文件
vim setting.xml
<server>
<id>ossrh</id>
<username>XXX(issues.sonatype.org 用户名,非Email)</username>
<password>XXX</password>
</server>
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.passphrase>XXX</gpg.passphrase>
<!-- windows平台 可省略 -->
<!--
<gpg.executable>/usr/local/bin/gpg</gpg.executable>
-->
</properties>
</profile>
<activeProfiles>
<activeProfile>ossrh</activeProfile>
</activeProfiles>
vim pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.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">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.snowthinker</groupId>
<artifactId>config-helper</artifactId>
<version>0.0.4-RELEASE</version>
<packaging><