手把手教学 本地jar上传maven中央仓库🚀🚀🚀

准备工作#

注册账号#

官网地址:https://central.sonatype.com/

注册命名空间#

  刚才注册好的账号,登录系统

验证namespace#

创建推送的账号密码#

复制内容如下

<server>
  <id>${server}</id>
  <username>xxxxxx</username>
  <password>xxxxxx</password>
</server>

把内容粘贴到maven的配置文件settings.xml中,${server}可以自定义。

 

GPG验证配置(这步很重要#

  GPG,全称为GNU Privacy Guard,是一个开源的加密软件,基于OpenPGP标准(RFC 4880)。它可以用于加密和解密数据、签名和验证数据,以及管理加密密钥。

下载地址:https://gnupg.org/download/index.html

生成密钥#

gpg --gen-key

根据提示输入真实姓名、邮箱(与git仓库邮箱一致),回车生成秘钥,此处会弹出弹框需要输入秘钥密码(后续上传jar会使用到)。

发布gpg秘钥#

  使用gpg命令上传秘钥到maven中央仓库,这样仓库持有了你的秘钥才能验证你的身份:

gpg --keyserver keyserver.ubuntu.com --send-keys xxxxxx

验证gpg秘钥(重要#

  能查到就代表密钥发布成功了

上传jar & 发布#

添加依赖#

复制代码
    <url>https://github.com/chenyanbin188/ybchen-super-cache-annotation</url>
    <description>Super cache annotation</description>


<licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>
    <developers>
        <developer>
            <id>chenyanbin</id>
            <name>chenyanbin</name>
            <email>543210188@qq.com</email>
            <roles>
                <role>Architect</role>
            </roles>
        </developer>
    </developers>
    <scm>
        <connection>https://github.com/chenyanbin188/ybchen-super-cache-annotation.git</connection>
        <developerConnection>https://github.com/chenyanbin188/ybchen-super-cache-annotation.git</developerConnection>
        <url>https://github.com/chenyanbin188/ybchen-super-cache-annotation</url>
    </scm>

    <build>
        <plugins>
            <plugin>
                <groupId>org.sonatype.central</groupId>
                <artifactId>central-publishing-maven-plugin</artifactId>
                <version>0.4.0</version>
                <extensions>true</extensions>
                <configuration>
                    <publishingServerId>chenyanbin</publishingServerId>
                    <tokenAuth>true</tokenAuth>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2</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-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </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>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>1.6</version>
                <configuration>
                    <executable>/usr/local/bin/gpg</executable>
                    <keyname>chenyanbin</keyname>
                </configuration>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
复制代码

推送#

查看发布成功的jar#

踩坑#

坑一:创建完namespace之后,发布的jar的包路径,两者要保持一致!!!

坑二:创建完namespace之后,不支持删除

 

posted @   陈彦斌  阅读(14)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
历史上的今天:
2020-03-04 网站10分钟不操作会话退出
点击右上角即可分享
微信分享提示
主题色彩