1.注册号
https://issues.sonatype.org/secure/Dashboard.jspa
2.新建一个项目
3.填写信息
概要啊什么的自己填一下
Group id 这个是 io.gitee.你gitee的空间地址
所以这里我的就是
io.gitee.continental-dada
Project URL 这个是你 gitee 仓库的地址
https://gitee.com/continental-dada/git-maven
SCM url 这个是克隆下面这个地址
4.回复信息,创建仓库
创建完后 在你创建的项目下面有注释 让你去创建一个仓库,证明你是这个这个仓库的拥有者,并且创建的这个仓库是要公开的public
创建好之后回复他已经创建完毕,等待回复。
回复之后,等待他的回复。如果回复这个了那么就代表创建成功了。
5.配置gpg4win
网站:https://www.gpg4win.org/thanks-for-download.html
下载完后,点击文件,新建一个Open这个证书 输入名字和邮箱就行
这个密码一定要记住
然后点这个上传就好
6.设置setting.xml
去idea找到mavn 里面的setting.xml中添加配置
找到地址,然后打开这个文件
放到servers中
<server>
<id>ossrh</id>
<username>xxx</username> //你的issues.sonatype.org账号
<password>xxxx</password> //你的issues.sonatype.org密码
</server>
2.放到profiles中
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.passphrase>dazhou520</gpg.passphrase> 生成密钥时填的密码
</properties>
</profile>
<profiles>
##6.配置pom.xml
然后在pom.xml文件中配置
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.14</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<!-- 新建的那个项目的groupId 跟网站中的要一样-->
<groupId>io.gitee.continental-dada</groupId>
<artifactId>dazhou-client-sdk</artifactId>
<version>0.0.1</version>
<name>dazhou-client-sdk</name>
<description>diaoy</description>
<properties>
<java.version>1.8</java.version>
<projectUrl>$https://gitee.com/continental-dada/git-maven.git</projectUrl> 项目的gitee地址 要加.git
<serverId>ossrh</serverId><!-- 服务id 也就是setting.xml中的servers.server.id -->
</properties>
<!-- 跟上传没关系-->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.9</version>
</dependency>
</dependencies>
<!--填入开发者信息,姓名、邮箱、项目地址-->
<developers>
<developer>
<name>dazhou</name> 随便填
<email>1797050390@qq.com</email> 随便填
<url>${projectUrl}</url>
</developer>
</developers>
<!--以下部分内容不需要修改,直接复制咱贴即可-->
<url>${projectUrl}</url>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo,manual</distribution>
</license>
</licenses>
<scm>
<!-- 采用projectUrl变量代替这个值,方便给重复利用这个配置,也就是上面的标签替换一下值就行 -->
<connection>${projectUrl}</connection>
<developerConnection>${projectUrl}</developerConnection>
<url>${projectUrl}</url>
</scm>
<distributionManagement>
<snapshotRepository>
<!--这个id和settings.xml中servers.server.id要相同,因为上传jar需要登录才有权限-->
<id>${serverId}</id>
<name>OSS Snapshots Repository</name>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<!--这个id和settings.xml中servers.server.id要相同,因为上传jar需要登录才有权限-->
<id>${serverId}</id>
<name>OSS Staging Repository</name>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<!-- 编译插件,设置源码以及编译的jdk版本 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<!--打包源码的插件-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc 文档生成插件-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<!-- 忽略生成文档中的错误 -->
<additionalparam>-Xdoclint:none</additionalparam>
<aggregate>true</aggregate>
<charset>UTF-8</charset><!-- utf-8读取文件 -->
<encoding>UTF-8</encoding><!-- utf-8进行编码代码 -->
<docencoding>UTF-8</docencoding><!-- utf-8进行编码文档 -->
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!--公钥私钥插件,也就是上传需要进行验证用户名和密码过程中需要用到的插件-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</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>
</plugins>
</build>
</project>
##7.测试推送
配置完点击 这个就好
看见这个则说明gpg4win配置对了。
出现SUCCESS则成功推送到了中仓库
成功页面
一般情况下Maven Central Repository Search会先出来
可以在这网站先看到
如果过了很久都没有出来,一般情况下idea都会自动完成以下步骤
在推送后
网站: https://s01.oss.sonatype.org/#stagingRepositories
然后登录这个网站 点击这个就能查看我们刚刚上传的
然后
close仓库
close实际是检测仓库的一个过程,检测没问题才可以发布
然后点击就可以从这个暂存库里面推送到 中心库了
参考:https://blog.csdn.net/SpongeBob_shouse/article/details/128803753?spm=1001.2014.3001.5502