Java项目上传到MavenCenter上步骤

https://central.sonatype.com注册 账号
  • 建议用github直接登录,因为在创建namespace的时候需要去验证,直接用github可以很快的验证结束。
    -可能遇到的问题 创建namespace失败,大概换成github登录就好了。
用GPG生成秘钥
  • 下载地址:https://www.gnupg.org/download/index.html
  • 生成证书 (先把GPG添加到环境变量中去)
    $ gpg --gen-key
  • 查询生成的证书


    image.png
  • 上传公钥到公钥服务器
    $ gpg --keyserver keyserver.ubuntu.com --send-keys 你的公钥
推送阶段
      <issueManagement>
        <system>github</system>
        <url>https://github.com/xxx/yyy/issues</url>
    </issueManagement>  
  • 配置 issueManagement
        <system>github</system>
        <url>https://github.com/xxx/yyy/issues</url>
    </issueManagement>
  • 配置 SCM
 <scm>
        <connection>scm:git:https://github.com/xxx/yyy.git</connection>
        <developerConnection>scm:git:https://github.com/xxx/yyy.git</developerConnection>
        <url>https://github.com/xxx/yyy</url>
    </scm>
  • settings.xml 文件配置
<servers>
    <server>
      <id>central</id>
      <username>xxx</username>
      <password>yyy</password>
    </server>
  </servers>
  <profiles>
    <profile>
      <id>gpg</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <gpg.executable>gpg</gpg.executable>
        <gpg.keyname>xxx@zzz.com</gpg.keyname>
        <gpg.passphrase>passphrase</gpg.passphrase>
        <gpg.useagent>true</gpg.useagent>
      </properties>
    </profile>
  </profiles>

其中username和password是在sonatype上生成的令牌


image.png
  • 执行构建并上传
    $ mvn clean deploy -Prelease
    或者在IDEA 上 点击 depely直接上传


    image.png
  • 上传结果


    image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容