This article teaches you to publish your personal development jar package to maven central repository

Keywords: Java Maven github nexus

Author: little brother Fu
Blog: -Original series special cases

Precipitation, sharing, growth, so that they and others can have a harvest! 😄

Introduction to foreword

(December, 19) recently, I want to make an open source sharing project based on Spring Boot, and develop a distributed task DcsSchedule middleware to enhance Schedule. If you encounter a problem, you want to contract Jar package to Maven central warehouse, so that users who need to use it can directly import it.

Release preparation

content remarks
1 To apply for a Github account: For uploading open source code:
2 GPG key generation tool: In the subsequent process, download, install and generate the key and upload it to the server. The server used in this paper is: hkp:// 80
3 Work order system: Responsible for applying for upload qualification and completing the first upload, subsequent updates do not need to be used, equivalent to a startup device
4 Component warehouse: The uploaded jar package will be stored here first. After Release, it can be released to maven central warehouse or set to be released automatically locally
5 Image warehouse: The final successful jar can be found here
6 Maven warehouse: After a few hours of patient waiting, we'll find it in Maven's warehouse
7 Alibaba cloud warehouse: Alicloud's warehouses will be synchronized faster
8 Personal domain name: This is mainly used for work order qualification verification (Add a TXT record to your DNS referencing this JIRA ticket: OSSRH-53637 (Fastest))

Follow the rhythm

1. Download and install the Gpg generation key

We need a GPG environment to encrypt and sign the uploaded files to ensure that your jar package is not tampered with

In 1991, Phil Zimmermann, a programmer, developed the encryption software PGP to avoid government surveillance. This software is very easy to use, spread quickly, and become a necessary tool for many programmers. However, it is commercial software and cannot be used freely. So the free software foundation decided to develop an alternative to PGP called GnuPG. This is the origin of GPG.

  1. Download address:
  2. After downloading, you can install it directly. It's easy to install it in a fool's way. Remember to choose Chinese (or not if you are hard in English)
  3. Generate key (can be generated using command line or directly in operation interface)

    1. File > new key pair (Ctrl+N) -- create a personal OpenPGP key pair

  1. Fill in personal information name and email and click New

  1. Fill in the key password

  1. Upload the public key to the directory service {if the upload fails, change the OpenPGP key server to: hkp://}

2. Work order system account registration issues.sonatype

1. Registered address:

2. Create work order

  • Project: community support - open source project repository housing
  • Summary: name of the publishing Jar
  • Description: not required, it is better to describe clearly
  • Group Id: org.itatack.middleware &It is related to your domain name, because it needs to be verified later
  • Project URL: Github project site(
  • SCM url: source repository(

3. Cooperate with manual audit

  1. When the completion order is created, information feedback will be received (there is a time difference between foreign countries and us, and they review it faster in the middle of the night);

    Do you own the domain If so, please verify ownership via one of the following methods:
    Add a TXT record to your DNS referencing this JIRA ticket: OSSRH-53637 (Fastest)
    Setup a redirect to your Github page (if it does not already exist)
    If you do not own this domain, please read:
    You may also choose a groupId that reflects your project hosting, in this case, something like io.github.fuzhengwei or com.github.fuzhengwei
    Would you like to use a free managed security reporting service (recommended)?
    Put as your project's security issue reporting URL. We'll take care of the rest.
    For more details on the Central Security Project, visit
  2. Configure domain name verification signature; TXT points to problem domain:

  3. In the screenshot of domain name verification, if the problem is answered, the manual verification will be carried out

  4. After the verification is successful, you will receive an email reply. You can also see it in the issues

     org.itstack.middleware has been prepared, now user(s) fuzhengwei can:
     * Deploy snapshot artifacts into repository
     * Deploy release artifacts into the staging repository
     * Release staged artifacts into repository 'Releases'
    please comment on this ticket when you promoted your first release, thanks
  1. Next, wait for the success of Jar package release, reply here and receive feedback, as follows (prove your success! );

    Central sync is activated for org.itstack.middleware. After you successfully release, your component will be published to Central, typically within 10 minutes, though updates to can take up to two hours.

3. Configure Maven Settings.xml

1. Maven Settings.xml Configuration, add in servers;

    <username> Account of < / username >
    <password> Password < / password >
    <username> Account of < / username >
    <password> Password < / password >
    <username> Account of < / username >
    <password> Password < / password >

2. In order to load Jar faster, Alibaba cloud warehouse is configured in mirrors;

  <name>aliyun maven repository</name>

3. Key configuration, add ossrh to profile

        <gpg.executable>D:/Program Files (x86)/GnuPG/bin/gpg.exe</gpg.executable>
        <gpg.passphrase>Key password generated above:</gpg.passphrase>
        <gpg.homedir>{find dir: cmd->gpg --list-key}C:/Users/fuzhengwei/AppData/Roaming/gnupg</gpg.homedir>

4. Configure POM file

1. Add scm, licenses, developers, and distribution management to the pom file

        <name>The Apache Software License, Version 2.0</name>




2. Configure build and gpg related plug-ins

  • Maven source plugin is used to generate Source Jar files
  • Maven javadoc plugin is used to generate javadoc documents
  • Maven GPG plugin is used to automatically sign engineering files
  • Nexus staging Maven plugin is used to publish projects to the central warehouse. In addition, when generating javadoc documents, you need to specify to close doclint. Otherwise, it may fail due to the use of irregular javadoc annotations. The complete configuration is as follows
<!-- release Jar reach Maven Warehouse Begin -->
<!--generate Source jar file-->
<!--generate Javadoc,close doclint,Avoid failing the annotation check-->
<!--Maven GPG The plug-in is used to sign components using the following configuration-->
<!--Nexus Staging Maven Plug in is to deploy components to OSSRH And publish it to Central Repository Recommended method-->
<!-- release plugin,For publishing to release Warehouse deployment plug-in -->
<!-- release Jar reach Maven Warehouse End -->

4. Execute publishing; idea Maven - > lifecycle - > deploy

  1. Next, the Jar package will be developed and released, and you will be prompted to enter the password when the key is generated
  2. View publication
  3. Go to "cooperate with manual audit" above, submit and publish the success information according to the instructions, and receive the reply after the verification is successful, as follows:;

    Central sync is activated for org.itstack.middleware. After you successfully release, your component will be published to Central, typically within 10 minutes, though updates to can take up to two hours.
  4. Search version information
  5. Alicloud warehouse is fast in synchronization and can be viewed

To sum up

  • The whole process is still very long. If you try it for the first time, well, you may have a sleepless night
  • You may encounter various abnormal errors in the middle, including key, packaging, publishing, etc. read the details of this article carefully and try many times by yourself, and you will succeed in the end
  • The same RELEASE version can only be uploaded once, otherwise it will fail. Foreigners really reply quickly in the middle of the night, because they happen to be at dawn in the middle of the night

Recommended reading

Posted by AdamSnow on Wed, 17 Jun 2020 20:05:34 -0700