上传jar包到maven官方仓库
参考:
https://central.sonatype.org/pages/ossrh-guide.html
https://www.sojson.com/blog/250.html
写一遍我自己成功上传的整个流程,遇到的错误,记录下来。
一、创建工单
1.注册账号
Username和Password要记住,这是部署到官方仓库的凭证,在maven的settings.xml中配置,后面会讲到。
2.创建工单
在这里遇到一个问题,当我点击create的时候,弹出来的窗口和上面我参考的那个人写的不一样,是这样的
没有出现Group Id 、Project URL、SCM url这三个必填项,当再次选择最上面的 Project
再次选择Community Support - Open Source Project Repository Hosting (OSSRH) 就出现了
按照要求填写就可以了,我有域名group id 填的 com.dcssn ,project url 填写 https://github.com/weiangongsi/ueditor-qiniu- spring-boot-starter 项目地址, scm url 填写 https://github.com/weiangongsi/ueditor-qiniu-spring-boot-starter.git git地址。这 里主要验证的是group id 唯一性,然后点击create
https://issues.sonatype.org/issues/?filter=-2 打开这个页面找到自己提交的工单
7分钟后他回复了一条信息,让我验证dcssn.com归我所有,第一种方式在dns解析中添加一个txt记录
记录值就是工单,我填写的是这个工单的url https://issues.sonatype.org/browse/OSSRH-42966
点击下面红色圈住的地方,跳转的就是工单地址
dns添加解析后,回复一下,等了5分钟后回复我了
这样就能发布jar包了,当发布成功后再告诉他已经发布了,就可以了。
二、上传jar包
1.maven settings.xml配置修改
<servers>
<server>
<id>sonatype-nexus-snapshots</id>
<username>上面申请的用户名</username>
<password>上面申请的密码</password>
</server>
<server>
<id>sonatype-nexus-staging</id>
<username>上面申请的用户名</username>
<password>上面申请的密码</password>
</server>
</servers>
2.pom文件修改
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dcssn</groupId>
<artifactId>ueditor-qiniu-spring-boot-starter</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>ueditor-qiniu-spring-boot-starter</name>
<description>百度编辑器向七牛云存储上传图片资源</description>
<url>https://github.com/weiangongsi/</url>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>8</version>
</parent>
<dependencies>
</dependencies>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>https://github.com/weiangongsi/ueditor-qiniu-spring-boot-starter</url>
<connection>https://github.com/weiangongsi/ueditor-qiniu-spring-boot-starter.git</connection>
<developerConnection>https://github.com/weiangongsi/</developerConnection>
</scm>
<developers>
<developer>
<name>lihaoyang</name>
<email>[email protected]</email>
<url>https://www.dcssn.com</url>
</developer>
</developers>
<distributionManagement>
<repository>
<id>sonatype-nexus-staging</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<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>
</plugins>
</build>
</project>
这些配置都是必须的,参照着改。
有gpg 签名这个东西,有点麻烦,第一天弄了半天也不行,第二天早上来上班,不知道怎么就行了,可能就是软件安装后要 重启吗?
双击打开,点击文件-》新建**对,选择创建个人OpenPGP**对
高级设置里面可以设置过期时间什么的,我没有设置,直接下一步
会有一个提示输入密码的窗口,这个密码不要忘记,maven setting.xml 会用到,maven deploy命令部署上传的时候会用到
创建成功后会在列表中显示,右键 在服务器上发布,成功后会提示导出成功
maven seetting.xml 加入gpg配置
<profiles>
<profile>
<id>sign-artifacts</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.passphrase>yycg888</gpg.passphrase>
</properties>
</profile>
</profiles>
三、发布
登录https://oss.sonatype.org/ 账号密码就是创建工单时申请的账号密码
选中后点击close ,close成功后点击Release 就发布了
在左边的search框中输入就能搜到了
第一次成功后要在那个工单下面回复一下,
deploy时遇到了 400 和 401 错误
401 是因为maven setting.xml中 用户名或密码填错了
<servers>
<server>
<id>sonatype-nexus-snapshots</id>
<username>***</username>
<password>***</password>
</server>
<server>
<id>sonatype-nexus-staging</id>
<username>***</username>
<password>***</password>
</server>
</servers>
400 是因为 快照仓库和正式仓库地址填反了
<distributionManagement>
<repository>
<id>sonatype-nexus-staging</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
Q群:806893930