首页 > 其他分享 >Maven项目通过maven central 发布到中央仓库 https://repo.maven.apache.org/ 手把手教学 最新教学

Maven项目通过maven central 发布到中央仓库 https://repo.maven.apache.org/ 手把手教学 最新教学

时间:2024-05-30 17:30:42浏览次数:20  
标签:central -- 教学 maven https apache org gitee

一、注册maven central账号

​ https://central.sonatype.com/publishing/namespaces
在这里插入图片描述
我这里直接使用github账号登录 ,可以自己注册或者直接使用google账号或者github账号登录
在这里插入图片描述

这里github账号登录之后 应该只出现io.github 下面的io.gitee我也验证过 所以这里出现了github和gitee 我这里直接以gitee为例

二、新增Namespace 并且通过验证

这里是一些开源仓库的命名方式
在这里插入图片描述

点击Add Namespace
在这里插入图片描述
这里我已经操作过了 我新增一个假的
在这里插入图片描述
在这里插入图片描述
出现了一个gitee的地址 以我之前的为例 https://gitee.com/dengbaikun/6cdhjdt1yz
打开我的gitee 新建仓库
在这里插入图片描述
必须是开源的
创建完之后
自己请求一下
https://gitee.com/dengbaikun/6cdhjdt1yz 能否访问 如果可以访问既可以通过验证了

三、配置GPG

到https://gpg4win.org/download.html 下载
在这里插入图片描述
进行安装
验证gpg是否验证成功
在这里插入图片描述
配置密钥
gpg --gen-key 生成key

gpg --list-keys 查看keys
在这里插入图片描述

# 发布公钥
gpg --keyserver keyserver.ubuntu.com --send-keys 5CC07AA0B6236AAC20C25D3421EA2B94594210D3
gpg --keyserver pgp.mit.edu --send-keys 5CC07AA0B6236AAC20C25D3421EA2B94594210D3
#发布密钥到 keys.openpgp.org
gpg --export 邮箱@foxmail.com > my_key.pub
#生成后my_key.pub 通过 https://keys.openpgp.org/upload 上传上去
#验证是否发布成功
gpg --keyserver keyserver.ubuntu.com --recv-keys 5CC07AA0B6236AAC20C25D3421EA2B94594210D3
gpg --keyserver keys.openpgp.org --recv-keys 5CC07AA0B6236AAC20C25D3421EA2B94594210D3
 gpg --keyserver pgp.mit.edu --recv-keys  5CC07AA0B6236AAC20C25D3421EA2B94594210D3

生成后my_key.pub 通过 https://keys.openpgp.org/upload 上传上去
生成后my_key.pub 通过 https://keys.openpgp.org/upload 上传上去

在这里插入图片描述

四、配置 maven的settings.xml

https://central.sonatype.com/account
在这里插入图片描述

<server>
  	<id>central</id>
    <username>asa2gZyr</username>
    <password>asdfvo4qXpAOFXNqiA6UQaa1Y6xJKRTuxZ7/MfYVeo1G</password>
</server>

把这段复制到 自己的maven的settings.xml文件中

五、配置 maven项目的pom

下面是必须的完成要加的内容

<properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <name>dengbaikun</name>
    <description>dengbaikun</description>
    <url>https://gitee.com/dengbaikun</url>

    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0</url>
        </license>
    </licenses>
    <developers>
        <developer>
            <name>dengbaikun</name>
            <email>自己的邮箱</email>
        </developer>
    </developers>
    <scm>
        <url>scm:git:[email protected]:dengbaikun/6cdhjdt1yz.git</url>
        <connection>scm:git:[email protected]:dengbaikun/6cdhjdt1yz.git</connection>
        <developerConnection>scm:git:[email protected]:dengbaikun/6cdhjdt1yz.git</developerConnection>
        <tag>master</tag>
    </scm>

    <distributionManagement>
        <snapshotRepository>
            <id>central</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>central</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-checkstyle-plugin</artifactId>
                        <version>3.1.2</version>
                        <configuration>
                            <skip>true</skip><!---跳过样式检查-->
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-pmd-plugin</artifactId>
                        <version>3.15.0</version>
                        <configuration>
                            <skip>true</skip>><!---跳过命令检查-->
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.6.3</version>
                        <configuration>
                            <encoding>UTF-8</encoding>
                            <charset>UTF-8</charset>
                            <docencoding>UTF-8</docencoding>
                            <additionalOptions>-Xdoclint:none</additionalOptions><!---
                            这里是为了跳过doc一些验证error变成warn警告 允许通过
                            -->
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.3.0</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-release-plugin</artifactId>
                        <version>3.0.1</version>
                        <configuration>
                            <autoVersionSubmodules>true</autoVersionSubmodules>
                            <mavenExecutorId>forked-path</mavenExecutorId>
                            <useReleaseProfile>false</useReleaseProfile>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <version>3.4.1</version>
                        <executions>
                            <execution>
                                <id>enforce-no-snapshots</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <requireReleaseDeps>
                                            <message>No Snapshots Allowed!</message>
                                            <onlyWhenRelease>true</onlyWhenRelease>
                                        </requireReleaseDeps>
                                    </rules>
                                    <fail>true</fail>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.1.0</version>
                        <configuration>
                            <gpgArguments>
                                <arg>--batch</arg>
                            </gpgArguments>
                        </configuration>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.4.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <tokenAuth>true</tokenAuth>
                            <autoPublish>true</autoPublish>
                            <waitUntil>validated</waitUntil>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

最后执行 mvn clean deploy -P release
在这里插入图片描述
然后我们根据上图的提示
打开https://central.sonatype.com/publishing/deployments
查看发布情况
在这里插入图片描述
等待变绿就可以

检验是否成功可以在这里搜索自己的artifactId
在这里插入图片描述
在这里插入图片描述
或者可以在 https://repo.maven.apache.org/maven2
这里打开看下有没有自己的包
在这里插入图片描述
出现了就代表成功了

六、拉取自己上传的中央仓库包(这里以为maven项目)

在pom中添加

<dependencies>
        <dependency>
            <groupId>io.gitee.dengbaikun</groupId>
            <artifactId>test-deploy</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>central</id>
            <url>https://repo.maven.apache.org/maven2</url>
        </repository>
    </repositories>
    

就会从repo.maven.apache.org/maven2 拉取刚发布的包

标签:central,--,教学,maven,https,apache,org,gitee
From: https://blog.csdn.net/weixin_42145354/article/details/139326486

相关文章

  • 关于 IDEA 2023.3.1总管理配置maven路径
    先调出主页面,再选择主页面中的maven路径配置1、调出主页面. 在设置中搜索System,选中SystemSettings模块,取消Confirm和Reopen模块的勾选     2、重新启动进入主页面点击Customise中的Allsettings,进入总设置,在此进行maven配置即可......
  • 推荐观看的Spring Boot Cloud教学视频!
    想要学习SpringBootCloud框架,但不知道从哪里开始?不用担心!我为您推荐一些高质量的教学视频,帮助您快速入门和深入理解这个流行的技术栈。......
  • Spring常用Maven配置
    基于Spring6的常用Mavenpom文件依赖配置(包含父工程设置以及SpringBoot及其相关项目依赖):<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.0.5</version&......
  • maven中排除依赖传递可以在pom.xml文件中使用exclusions标签
    在项目A中引入项目B的依赖,通过依赖传递,会把项目B中的jar都引进来,如果在项目A中不想使用项目B中的某些jar包,可以使用exclusions标签进行排除,具体该标签的用法:<!--mybatis-spring依赖--><dependency><groupId>org.mybatis</groupId>......
  • Maven
    1.Maven简介        1.1为什么要使用Maven?            传统方式构建的web项目                         特点:项目中使用jar包,需要重复的复制到项目的lib中                maven方式创建的web项目 ......
  • CUDA教学(1):前向转播
    一个简单的CUDA实践。用于实现前向传播。一、算法设计(一)问题背景描述和算法设计?问题描述:计算某个点f的特征值的“插值”结果。以二维为例,为了“插值”得到f的特征值,需要用到:各顶点的特征值\(f_i\)和f距离该顶点对面的两条边的距离的乘积之和。如果扩展到三维,那么需......
  • CUDA教学(2):反向传播
    cuda没有提供自动求导机制,因此我们需要完成以下两步,实现反向传播。一、计算所有trainable参数的偏微分判断哪些参数是trainable的?本例中,输入f的坐标是固定的,所以uvw的值也是固定的,因此只需要求feats_interp对各个顶点的特征量\(f_i\)的偏微分即可。‍如何进行反......
  • AI绘画整合包最新Stable Diffusion安装包+教程+模型+插件+动作来了(纯教学)
    首先了解一下AI绘画工具,介绍一下什么是StableDiffusion,模型的主要功能和作用StableDiffusion(简称SD),是一种先进的人工智能技术。这项技术的核心能力在于,它能够根据用户提供的文字描述,生成丰富且细致的图像内容。不仅如此,SD还能够处理图像修补、扩展以及基于文本指导的图像转......
  • Maven中各种scope的区别
    Maven中各种scope的区别compile,默认,参与编译,测试,运行,打包等过程,大部分依赖都是这个test,仅参与测试代码的编译,运行,如junitruntime,参与测试,运行,打包,不编译,如mysql-connnectorprovided,参与编译,测试,运行,不打包,如java.servlet-apisystem,参与编译,测试,运行,不打包,从本地系统读取,......
  • IDEA2023版本的Maven设置永久生效
    问题描述:每次创建一个新的项目Maven都会失效,都要重新配置。 解决方法:点击File—>NewProjectsSetup—>SettingsforNewProjects。 输入mvn,跟前面一样设置Mavenhomepath、Usersettingfile、Localrepository。完成后一定要重启!!!! ......