Nexus builds Maven private library introduction

Why do you need a Maven private library?

When using Maven to obtain Java dependency packages, the default is to download the jar file from Maven's central library. The address of the central library is: https://repo.maven.apache.org/maven2 . If the download speed is slow, you can use Ali’s mirror, the address is as follows:
https://maven.aliyun.com/repository/public

The above scenarios are all developed when the Internet network is unblocked. However, in many internal development environments of enterprises, due to security considerations, some machines in the internal network of the enterprise are prohibited from accessing the external network. If not, neither the Maven default library nor the Ali mirror library can be used, and the dependencies will naturally not be downloaded.

In addition to the above scenarios, there is another scenario for internal development of the enterprise, that is, the internal applications of the enterprise use the https protocol, and the internal https root certificate is issued and applied on the internal machine to replace the default https certificate mechanism. This may occur One of the problems is that when Java uses certificates to access https sites, it will consider Maven's central library as insecure. Although this problem can be solved, it is always inconvenient. For related problems and solutions, please refer to: Maven cannot download
dependencies PKIX path building failed problem and solution

In addition, obtaining dependencies from central libraries or network mirrors has the following problems:

  • Team development, everyone downloads from the central library or Alibaba Cloud mirror warehouse, wasting time and network resources.
  • Self-developed packages that cannot be published to the central library are troublesome to maintain
  • Some third-party packages with licenses are not available in the central library (such as Oracle's JDBC)
  • Some old or specific versions, the central repository does not exist

Based on the above reasons, these problems can be solved if a Maven private library is built internally.

What to use to build a Maven private library?

There are many tools for building Maven private libraries, the recommended one is Nexus.

Nexus site address is:
https://www.sonatype.com/thanks/repo-oss

Go to this address to see related downloads and introductions.
insert image description here

Downloads for Nexus

The official download page is shown above. The current latest version is nexus-3.55.0-01. The download address corresponding to each operating system is:

  • Unix : https://download.sonatype.com/nexus/3/nexus-3.55.0-01-unix.tar.gz
  • Windows :https://download.sonatype.com/nexus/3/nexus-3.55.0-01-win64.zip
  • Mac OS : https://download.sonatype.com/nexus/3/nexus-3.55.0-01-mac.tgz

Note: The download from the official address is likely to be unsuccessful. You can download it from the following network disk:

Link: https://pan.baidu.com/s/1_51k9C_ORDPmueHoQ9Bsjw?pwd=00ru
Extraction code: 00ru

Launch of Nexus

This article is based on the Windows version. The downloaded file is a zip file nexus-3.55.0-01-win64.zip, after decompressing the file, there are two directories:

insert image description here

nexus-3.55.0-01 includes files related to nexus itself, such as the startup file of exe, and sonatype-work mainly runs related directories.

Switch to the nexus-3.55.0-01\bin directory from the command line and execute nexus /run
insert image description here

The following page appears, which means the startup is successful

insert image description here

After the startup is complete, enter http://localhost:8081/ in the browser:

insert image description here

Basic use of Nexus

View local libraries

Click the cube above, and then click Browse on the left navigation bar to see the included library, as shown below:

insert image description here

There are mainly two types of maven and nuget here, and here we only look at maven.

  • maven-center, the central library, if you can connect to the network, you can set the address of Maven official library or Ali mirror library
  • maven-public, is a group that can contain maven-releases, maven-sanpshots, etc.
  • maven-releases, publish stable versions of local development packages
  • maven-sanpshots , publish a snapshot version of the local development package, that is, a draft version

management library

You don’t need to log in to view the library, but you need to log in first to manage the library. Click Sign In in the upper right corner to log in

insert image description here

Use the admin account to log in. The default password is located in sonatype-work\nexus3\admin.password. After the login is complete, you will be asked to change the password.

insert image description here

After login, there is an Upload menu on the left navigation bar of the page, which can upload dependent packages. There is one more gear button at the top for library configuration and management.

insert image description here

The page after clicking the configuration button is as follows:

insert image description here



Guess you like

Origin blog.csdn.net/oscar999/article/details/131276196