一、在sonatype注册账号,申请审核

二、gpg加密

三、修改pom

四、mvn提交

######1. 登录https://issues.sonatype.org/login.jsp

######2. 点击
createQQ截图20190222093355

######3. 输入必选项
QQ截图20190222093827
要注意groupId,可以使用
例如com.github.用户名
com.gitee.用户名
io.github.用户名
如果要使用自己公司名称的,需要按照要求提供
QQ图片20190222094920

######4. 等待审核,有时差,所以一般要到第二天

######5. 当状态为resolvedQQ截图20190222095126

######6. 查看下面多了个信息QQ截图20190222095240这就表示可以上传jar了

######7. 当你在等待审核的时候可以先进行其他步骤
先在https://www.gnupg.org/ 下载并安装Gpg4win(本人用的windows)
打开命令行输入命令,按提示输入用户名、邮箱、密码(这个需要记下来)

gpg --gen-key
//最后的字符串为公钥Id
gpg --keyserver hkp://keyserver.ubuntu.com:11371 --send-keys FF665B35F0CA0F0F

######8. 修改pom,添加

<profiles>
    <profile>
        <id>release</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>1.6.3</version>
                    <extensions>true</extensions>
                    <configuration>
                        <serverId>oss</serverId>
                        <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                        <autoReleaseAfterClose>true</autoReleaseAfterClose>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>2.5</version>
                    <configuration>
                        <autoVersionSubmodules>true</autoVersionSubmodules>
                        <useReleaseProfile>false</useReleaseProfile>
                        <releaseProfiles>release</releaseProfiles>
                        <goals>deploy</goals>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.0</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                </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.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</version>
                    <executions>
                        <execution>
                            <id>attach-javadocs</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                            <configuration>
                                <additionalparam>-Xdoclint:none</additionalparam>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

<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://gitee.com/xxx/xxx</url>
    <connection>https://gitee.com/xxx/xxx.git</connection>
    <developerConnection>https://gitee.com/xxx</developerConnection>
</scm>

<developers>
    <developer>
        <name>xxx</name>
        <email>xxx@hotmail.com</email>
    </developer>
</developers>

<distributionManagement>
    <snapshotRepository>
        <!-- 这个id需要在setting.xml中设置 -->
        <id>oss</id>
        <name>OSS Snapshots Repository</name>
        <!-- 这里的url就是Issue中回复的snapshots 的repo地址 -->
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
        <id>oss</id>
        <name>OSS Staging Repository</name>
        <!-- 这里的url就是Issue中回复的staging 的repo地址 -->
        <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
    </repository>
</distributionManagement>

######9. 修改maven的setting.xml

<servers>
    <server>
      <id>oss</id>
      <username>Sonatype 账号</username>
      <password>Sonatype 密码</password>
    </server>
</servers>

######10. 命令行输入mvn clean deploy -P release(我这里用eclipse提示找不到gpg命令,本机上安装有maven,所以可以直接在命令行打mvn命令)
在弹出框中输入生成gpg秘钥时候的密码
如果build success
几分钟后就可以在https://oss.sonatype.org/content/groups/public/ 查看到提交的文件
等待一段时间(可能得大半天)可以在maven仓库中搜索到