吕子乔做网站一段台词,专业推广引流团队,数字广东网络建设有限公司招聘,企业营销微网站建设文章目录注册账号GPG 安装安装生成密钥上传公钥Maven配置上传到Maven仓库修改项目的配置#xff0c;填写基本信息执行编译命令登录网站配置发布项目中应用遇到的问题解决方法本文将介绍如何将自己的jar包发布至公共的中央仓库#xff0c;通过maven方式进行引用 注册账号
注册…
文章目录注册账号GPG 安装安装生成密钥上传公钥Maven配置上传到Maven仓库修改项目的配置填写基本信息执行编译命令登录网站配置发布项目中应用遇到的问题解决方法本文将介绍如何将自己的jar包发布至公共的中央仓库通过maven方式进行引用 注册账号
注册地址 https://issues.sonatype.org/secure/Signup!default.jspa 填写基础信息 这里我使用gitee做提交网络不太好连GitHub有些卡逻辑是一样的。 点击创建 填入相关信息 填写信息说明:
字段填写内容Summary概要(写jar包是做什么用的可以中文)Description描述(详细描述jar包是做什么用的可以与Summary相同可以中文)Group Ide.g. com.gitee.jast (这里使用gitee做demo)Project URLe.g. https://gitee.com/jastee/jast-toolSCM urle.g. https://gitee.com/jastee/jast-tool.gitProejct选择 Community Support - Open Source Project Repository Hosting (OSSRH)Issue Type选择 New Project
填写完成点击create创建
提交完成之后状态为开放 英文版如下后续用英文版进行介绍
然后等待官方人员审核随后官方人员回复让我们在gitee上创建一个空项目验证该gitee是自己的账号。(期间很尴尬我创建完了项目没设置公开权限自己能访问他不能访问我就一直问他他也不说啥原因就让我创建空项目。。。) 当状态变成Status:RESOLVED则是可以发包了
GPG 安装
安装
brew install gpg 如果在线安装不了则可以直接下载(我是在线安装的) https://gpgtools.org/
生成密钥
# 根据提示输入用户名,邮箱,密码 要记住后面需要用
gpg --gen-key查看生成的密钥
macMac ~ % gpg --list-keys
gpg: 正在检查信任度数据库
gpg: marginals needed: 3 completes needed: 1 trust model: pgp
gpg: 深度0 有效性 1 已签名 0 信任度0-0q0n0m0f1u
gpg: 下次信任度数据库检查将于 2023-10-23 进行
/Users/mac/.gnupg/pubring.kbx
-----------------------------
pub ed25519 2021-10-23 [SC] [有效至2023-10-23]1D3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF325
uid [ 绝对 ] jast 745925668qq.com
sub sb11111 2021-10-23 [E] [有效至2023-10-23]1D3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF325(这里公钥为了演示我随便改了下我实际的公钥不是这个上传是要传实际的)这个就是公钥一会要上传到密钥服务器
上传公钥
macMac ~ % gpg --keyserver hkp://keyserver.ubuntu.com:11371 --send-keys 1D3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF325
gpg: 正在发送密钥 AAAAAAAAAAAAAAAAAAAF325 到 hkp://keyserver.ubuntu.com:11371查看上传的公钥
# 网络原因可能会接收失败多执行两次可以查看到成功
macMac ~ % gpg --keyserver hkp://keyserver.ubuntu.com:11371 --recv-keys 1D3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF325
gpg: 从公钥服务器接收失败No data
macMac ~ % gpg --keyserver hkp://keyserver.ubuntu.com:11371 --recv-keys 1D3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF325
gpg: 密钥 D1BC8A428AA3F325“jast 745925668qq.com” 未改变
gpg: 处理的总数1
gpg: 未改变1Maven配置
在Maven的setting.xml中添加账号信息 server idossrh/idusername第一步注册的账号/usernamepassword第一步注册账号的密码/password/server上传到Maven仓库
修改项目的配置填写基本信息
Java项目中pom.xml配置如下
?xml version1.0 encodingUTF-8?
project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdcom.gitee.jastee/groupIdartifactIdjast-tool/artifactIdversion0.0.2/versionnamejast-tool/namedescriptionJava 工具/descriptionurlhttps://gitee.com/jastee/jast-tool/urllicenseslicensenameThe Apache Software License, Version 2.0/nameurlhttp://www.apache.org/licenses/LICENSE-2.0.txt/urldistributionrepo/distribution/license/licensesissueManagementsystemgitee/systemurlhttps://gitee.com/jastee/jast-tool/issues/url/issueManagementscmconnectionscm:git:https://gitee.com/jastee/jast-tool.git/connectiondeveloperConnectionscm:git:https://gitee.com/jastee/jast-tool.git/developerConnectionurlhttps://gitee.com/jastee/jast-tool/url/scmdevelopersdevelopernameJast/nameemail745925668qq.com/emailurlhttps://gitee.com/jastee/url/developer/developerspropertiesproject.build.sourceEncodingUTF-8/project.build.sourceEncodingproject.reporting.outputEncodingUTF-8/project.reporting.outputEncodingjava.version1.8/java.version/propertiesdistributionManagementrepositoryidossrh/id
!-- urlhttps://oss.sonatype.org/service/local/staging/deploy/maven2//url--urlhttps://s01.oss.sonatype.org/service/local/staging/deploy/maven2//url/repositorysnapshotRepositoryidossrh/id
!-- urlhttps://oss.sonatype.org/content/repositories/snapshots/url--urlhttps://s01.oss.sonatype.org/content/repositories/snapshots//url/snapshotRepository/distributionManagementbuildpluginManagementpluginsplugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-compiler-plugin/artifactIdconfigurationsource1.8/sourcetarget1.8/target/configuration/pluginplugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-release-plugin/artifactIdconfigurationmavenExecutorIdforked-path/mavenExecutorIduseReleaseProfilefalse/useReleaseProfilearguments-Psonatype-oss-release/arguments/configuration/pluginplugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-source-plugin/artifactIdversion3.1.0/versioninheritedtrue/inheritedexecutionsexecutionidattach-sources/idgoalsgoaljar/goal/goals/execution/executionsconfigurationexcludeResourcestrue/excludeResourcesuseDefaultExcludestrue/useDefaultExcludes/configuration/pluginplugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-javadoc-plugin/artifactIdversion3.0.0/versioninheritedtrue/inheritedexecutionsexecutionidbundle-sources/idphasepackage/phasegoalsgoaljar/goal/goals/execution/executionsconfigurationmaxmemory1024/maxmemoryencodingUTF-8/encodingshowprotected/shownotreetrue/notree!-- Avoid running into Java 8s very restrictive doclint issues --failOnErrorfalse/failOnErrordoclintnone/doclint/configuration/plugin/plugins/pluginManagementpluginsplugingroupIdorg.codehaus.mojo/groupIdartifactIdcobertura-maven-plugin/artifactIdversion2.7/versionconfigurationformatsformathtml/formatformatxml/format/formatscheck//configuration/pluginplugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-resources-plugin/artifactIdversion3.1.0/versionconfigurationencodingUTF-8/encoding/configuration/pluginplugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-compiler-plugin/artifactId/pluginplugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-javadoc-plugin/artifactId/pluginplugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-source-plugin/artifactId/plugin/plugins/buildprofilesprofileidrelease/idbuildpluginsplugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-gpg-plugin/artifactIdversion1.6/versionexecutionsexecutionidsign-artifacts/idphaseverify/phasegoalsgoalsign/goal/goals/execution/executions/plugin/plugins/build/profile/profiles/project执行编译命令
编译过程中需要输入之前我们密钥的密码 mvn clean deploy -DskipTeststrue -P release
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 50.101 s
[INFO] Finished at: 2021-10-24T10:15:5408:00
[INFO] ------------------------------------------------------------------------可能会遇到的问题问题 打包上传报错 mvn clean deploy -DskipTeststrue -P release
gpg: 签名时失败 Inappropriate ioctl for device
gpg: signing failed: Inappropriate ioctl for device解决方法 设置环境变量 export GPG_TTY$(tty)重新执行mvn clean deploy -DskipTeststrue -P release会弹出一个密码输入界面输入我们之前设置密钥的密码即可 登录网站配置发布
https://s01.oss.sonatype.org/#stagingRepositories
点击 Staging Repositories - 勾选我们要发布的jar包 - 点击Close 提交完稍等一会刷新就可以看到提示status为closed可以进行下一步 点击release 搜索我们发布的Jar包 可以看到我们发布的Jar包每个版本的包只能提交一次不能重复提交到公共仓库 注意这里不要发布成SNAPSHOT版本了 在中央仓库直接查看也可以看到我们传的jar包
项目中应用
加入依赖进行下载发现jar包成功下载 测试应用可以正常使用 需要更新jar包时我们修改版本号mvn clean deploy -DskipTeststrue -P release然后提交到仓库发布,执行 closed - release 即可。
上传完成后我们可以直接在pom.xml中引用在https://mvnrepository.com/ 搜索到需要等几个小时上传完不能直接看到。 至此我们上传到中央仓库成功。
遇到的问题解决方法 中间遇到了个小插曲 上传之后提示了三个错误 点击Activity查看 提示说少各种POM信息 Invalid POM: /com/gitee/jastee/jast-tool/0.0.1/jast-tool-0.0.1.pom: Project name missing, Project description missing, Project URL missing, License information missing问题原因 pom.xml中文件少配置了相关参数配置一定要和我上面列的一样。