上傳jar包到maven官方倉庫
參考:
寫一遍我自己成功上傳的整個流程,遇到的錯誤,記錄下來。
一、建立工單
Username和Password要記住,這是部署到官方倉庫的憑證,在maven的settings.xml中配置,後面會講到。
2.建立工單
在這裡遇到一個問題,當我點選create的時候,彈出來的視窗和上面我參考的那個人寫的不一樣,是這樣的
沒有出現Group Id 、Project URL、SCM url這三個必填項,當再次選擇最上面的 Project
再次選擇Community Support - Open Source Project Repository Hosting (OSSRH) 就出現了
7分鐘後他回覆了一條資訊,讓我驗證dcssn.com歸我所有,第一種方式在dns解析中新增一個txt記錄
點選下面紅色圈住的地方,跳轉的就是工單地址
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>上面建立金鑰的密碼</gpg.passphrase>
</properties>
</profile>
</profiles>
三、釋出
選中後點擊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>
釋出快照版本
pom.xml 中的 版本加上-SNAPSHOT
<version>0.0.1-SNAPSHOT</version>
釋出正式版本 不加-SNAPSHOT就行了
<version>0.0.1</version>
Q群:806893930