当前位置: 首页 > wzjs >正文

做网站需要知道的简单代码如何实现网站的快速排名

做网站需要知道的简单代码,如何实现网站的快速排名,南通做网站价格,手表价格网站欢迎来到我的博客,代码的世界里,每一行都是一个故事 🎏:你只管努力,剩下的交给时间 🏠 :小破站 打造自己的开源组件:如何将 Starter 发布到 Maven Central? 一、准备工作…

欢迎来到我的博客,代码的世界里,每一行都是一个故事


在这里插入图片描述

🎏:你只管努力,剩下的交给时间

🏠 :小破站

打造自己的开源组件:如何将 Starter 发布到 Maven Central?

    • 一、准备工作
    • 注册 OSSRH 账号并创建项目空间
    • 安装配置GPG
    • 生成发布令牌
    • 配置发布

本文将详细介绍如何将你开发的 Java Starter 组件发布到 Maven Central,涵盖从项目准备、GPG 签名、Sonatype 注册、Nexus 配置、到最终发布的完整流程。通过一个真实项目为例,带你快速掌握整个发布链路,避免踩坑,助你轻松构建自己的开源组件生态!

开发自己的 Starter 很爽,但你有没有想过让全球的 Java 开发者都能 引入它?这就需要你把它发布到 Maven Central

然而,第一次发布总是伴随着各种“仪式感”:GPG 密钥、Sonatype 审核、签名校验失败、POM 配置报错……是不是已经劝退了不少人?

别担心,这篇文章将用最通俗易懂的方式,手把手带你把自己的 Java 组件优雅地发布到 Maven Central

一、准备工作

  • ✅ 拥有一个已经发布成功的 Java 项目(以我的acowbo-excel-starter 为例)
  • ✅ 注册 Sonatype OSSRH
  • ✅ 安装并配置 GPG(用于代码签名)
  • ✅ 生成发布令牌
  • ✅ 拥有 GitHub 仓库(开源项目推荐)

注册 OSSRH 账号并创建项目空间

大家可以在这个网址进行注册https://central.sonatype.com/,我是直接使用的谷歌邮箱,当然还支持github。注册登录之后进行命名空间的创建。命名建议直接使用github的,也就是io.github.你的名称,然后会出现验证命名空间,如下图:
image-20250520102416745

验证成功提醒
image-20250520102503216

至此就完成了第二步操作🔚

安装配置GPG

这一步是必须的,而且建议使用脚本来配置,控制台我试了一下,交互不是那么好。

  1. 创建一个txt文件

    Key-Type: RSA
    Key-Length: 2048
    Name-Real: acowbo
    Name-Email: abcd@gmail.com
    Expire-Date: 0
    Passphrase: 123456
    %commit
    

    这里只需要注意名称、邮箱、以及密码。别的按照我的填写即可!

  2. 执行命令gpg --batch --gen-key key-config.txt

    image-20250521100943706

  3. 执行gpg --list-keys获取到key id,下一步会用到

    image-20250521101615894

  4. 上传到公钥服务器

    gpg --keyserver hkp://keyserver.ubuntu.com --send-keys 上一步的key id
    gpg --keyserver hkp://keys.openpgp.org --send-keys 上一步的key id
    

生成发布令牌

地址为:https://central.sonatype.com/account

image-20250521102025446

保存这个令牌,后续会用到

配置发布

首先需要根据你刚刚获取到的用户令牌放到你使用的maven的setting.xml中,如下

<settings><servers><server><id>central</id><username><!-- your token username --></username><password><!-- your token password --></password></server></servers>
</settings>

上面提到的都完成后就需要配置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>io.github.acowbo</groupId><artifactId>acowbo-excel-starter</artifactId><version>1.0.0</version><packaging>jar</packaging><name>acowbo-excel-starter</name><description>Excel import/export starter for Spring Boot</description><url>https://github.com/acowbo/acowbo-excel-starter</url><!-- 许可证信息 --><licenses><license><name>The Apache License, Version 2.0</name><url>http://www.apache.org/licenses/LICENSE-2.0.txt</url></license></licenses><!-- 开发者信息 --><developers><developer><name>acowbo</name><email>todoitbo@gmail.com</email><organization>acowbo</organization><organizationUrl>https://github.com/acowbo</organizationUrl></developer></developers><!-- SCM 信息 --><scm><connection>scm:git:git://github.com/acowbo/acowbo-excel-starter.git</connection><developerConnection>scm:git:ssh://github.com:acowbo/acowbo-excel-starter.git</developerConnection><url>https://github.com/acowbo/acowbo-excel-starter/tree/master</url></scm><build><plugins><!-- 生成源码JAR --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-source-plugin</artifactId><version>3.2.1</version><executions><execution><id>attach-sources</id><goals><goal>jar-no-fork</goal></goals></execution></executions></plugin><!-- 生成JavaDoc JAR --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-javadoc-plugin</artifactId><version>3.3.1</version><executions><execution><id>attach-javadocs</id><goals><goal>jar</goal></goals></execution></executions></plugin><!-- GPG签名 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-gpg-plugin</artifactId><version>1.5</version><configuration><passphrase>${env.GPG_PASSPHRASE}</passphrase></configuration><executions><execution><id>sign-artifacts</id><phase>verify</phase><goals><goal>sign</goal></goals></execution></executions></plugin><!-- Central发布插件 --><plugin><groupId>org.sonatype.central</groupId><artifactId>central-publishing-maven-plugin</artifactId><version>0.7.0</version><extensions>true</extensions><configuration><publishingServerId>central</publishingServerId><!-- <tokenAuth>true</tokenAuth> &lt;!&ndash; 如果使用token认证 &ndash;&gt; --></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>8</source><target>8</target></configuration></plugin></plugins></build>
</project> 

具体的配置要求大家也可以看这个文档:https://central.sonatype.org/publish/requirements/#provide-file-checksums

然后执行一个脚本

#!/bin/bash
# deploy.sh# 设置GPG密码为环境变量
export GPG_TTY=$(tty)
export GPG_PASSPHRASE="你刚刚配置的gpg密码"# 执行Maven命令
mvn clean deploy --settings /Users/xiaobo/webSoft/apache-maven-3.8.1/conf/settings_to_private_mvn.xml# 清理环境变量
unset GPG_PASSPHRASE

⚠️:这里说明一下为什么我执行settings,因为我发现没有走我在idea中设置的。也建议大家这种做,保险一点

发布成功页面


文章转载自:

http://N8o5oJbe.zwpzy.cn
http://SLbx2lHx.zwpzy.cn
http://TSRrAUQm.zwpzy.cn
http://85q4lkvm.zwpzy.cn
http://SZEY5mQ8.zwpzy.cn
http://RcuDNBms.zwpzy.cn
http://4rXnHMnW.zwpzy.cn
http://Epep8bvQ.zwpzy.cn
http://UNiODI4F.zwpzy.cn
http://8aF7Axcc.zwpzy.cn
http://WjbstcV6.zwpzy.cn
http://imRUAXZg.zwpzy.cn
http://wzIcYEff.zwpzy.cn
http://22NsFPj8.zwpzy.cn
http://nYyNIvje.zwpzy.cn
http://qoEZ5CWg.zwpzy.cn
http://el8iDMfG.zwpzy.cn
http://UE7fUOpk.zwpzy.cn
http://ajWjyAzd.zwpzy.cn
http://V5IC4zVP.zwpzy.cn
http://VV3aVOiU.zwpzy.cn
http://vZmh6UUl.zwpzy.cn
http://V22GJGMG.zwpzy.cn
http://PfA04ERA.zwpzy.cn
http://Pv9QjC1p.zwpzy.cn
http://9JL9EXrQ.zwpzy.cn
http://9nKqA13M.zwpzy.cn
http://I7Oc6zG1.zwpzy.cn
http://B5I3tcNI.zwpzy.cn
http://Y8t6uCSJ.zwpzy.cn
http://www.dtcms.com/wzjs/750956.html

相关文章:

  • 不需要付费的网站建设官网网址
  • 网站导航排版布局wordpress 调用数据库
  • 德州网站有哪些平面设计技术培训机构
  • php音乐网站设计沛县徐州网站开发
  • 建设一个视频网站己18网站开发图片存哪里
  • 一句话介绍网站开发做网站课程报告
  • 天津市建设安全协会网站wordpress首页分类
  • 做施工的平台网站装饰设计资质乙级
  • 展示型网站搭建网站建设 xplogo
  • 西安网站制作公司花禾科技手机网站建设规划书
  • 网站建设公司的网销好做吗申请阿里巴巴网站首页
  • 做外贸用什么网站比较好企业网站功能介绍
  • 网站建设找业主签字模板网站建设的运用场景
  • wordpress图片不同分辨率搜索引擎优化规则
  • 网站案例模板centos wordpress 空白
  • 做物流网站的多少钱大学生水果预定配送网站建设的项目规划书
  • 织梦网站模板安装教程lamp 搭建wordpress
  • 网站开发三层架构电商平台寻求供货商
  • 网站广告网络推广价格低wordpress能做cms
  • 安装wordpress提示建立数据库连接时出错北京做网络优化的公司
  • 最早做淘宝返利的网站wordpress和vue
  • 招聘网站建设价格摩托车建设网站
  • 有了代刷网的源码怎么做网站什么网站是solr做的
  • 网站建设销售渠道厦门移动网站建设哪家专业
  • 如何识别网站的建站程序使用pycharm网站开发
  • 哪个网站可以做行程药品和医疗器械网站icp备案前置审批流程
  • 平凉北京网站建设asp个人网站模板下载
  • c语言做的网站有什么优缺点用php做网站的优势
  • 东莞营销型网站建站中国十大猎头公司
  • 福州网站制作费用自己做的网站某个网页打开很慢