Build maven private server, publish the project to maven private server, Download jars from private server to local warehouse, and install third-party jars to local warehouse and maven private server

maven private server

1.1 build maven private server

① Download nexus

② Install nexus

Unzip the downloaded compressed package and enter the bin directory

Open the cmd window and enter the bin directory above, execute the nexus.bat install command to install the service (note that you need to run the cmd command as an administrator)

③ Start nexus

After completing the installation of nexus through the previous command, execute nexus.bat start command on the command line to start nexus

④ Access nexus

After starting the nexus service, access http://localhost:8081/nexus

Click the LogIn button in the upper right corner to log in. Log in to the system with the default user name admin and password admin123

nexus warehouse type

nexus has many built-in warehouses by default. These warehouses can be divided into four types. Each type of warehouse is used to store specific jar packages. The details are as follows:

① Hosted, the hosted warehouse, deploys its own jar s to this type of warehouse, including releases and Snapshots. Releases is the company's internal release version warehouse and Snapshots is the company's internal test version warehouse

② Proxy, proxy warehouse, is used to proxy remote public warehouses, such as maven central warehouse. Users connect to private servers. Private servers automatically go to the central warehouse to download jar packages or plug-ins

③ Group, warehouse group, is used to merge multiple hosted/proxy warehouses. Usually, we configure our own maven connection warehouse group

④ Virtual: jar or plug-in compatible with Maven 1 version

Correspondence between nexus warehouse type and installation directory

1.2 (key) publish the project to maven private server

Maven private server is a maven warehouse built in the company's LAN, which can be used by all development teams in the company. For example, if the technology R & D team develops a basic component, it can make a jar package and publish it to the private server. Other team members can download the jar package from the private server to the local warehouse and use it in the project.

The steps to publish the project to maven private server are as follows:

  1. Configure maven's settings.xml file

Note: it must be configured in maven's settings.xml file introduced in idea tool

  1. pom.xml file for configuration project

3. Execute the mvn deploy command

1.3 (key) Download jar from private server to local warehouse

The specific operation steps are as follows:

<!--Step 1: in maven of settings.xml Configure download template in file-->
		<!--Warehouse address, i.e nexus Address of warehouse group-->
		<!--Download releases component-->
		<!--Download snapshots component-->
    <!-- Plug in warehouse, maven The operation of depends on the plug-in, and you also need to download the plug-in from the private server -->
	<name>Public Repositories</name>
<!--Step 2: in maven of settings.xml The activation download template is configured in the file, which corresponds to the activation template profile of id-->

1.4 install the third-party jar into the local warehouse and maven private server

After configuring the coordinates of a jar package in the pom.xml file of the Maven project, if the jar package does not exist in the local Maven warehouse, the Maven tool will automatically download it to the configured Maven private server. If it does not exist in the private server, the Maven private server will download it from the maven central warehouse.

However, not all jar packages can be downloaded from the central warehouse. For example, the commonly used Oracle database driven jar packages do not exist in the central warehouse. At this time, you need to download the driver jar package from Oracle's official website, and then install the jar package into our local maven warehouse or maven private server through maven command, so that you can use maven coordinates to reference this jar package in maven project.

1.4.1 install the third-party jar into the local warehouse

① Download Oracle jar package (omitted)

② Install with the mvn install command

​ mvn install:install-file -Dfile=ojdbc14- -DartifactId=ojdbc14 –

​ Dversion= -Dpackaging=jar

③ Check the local maven warehouse and confirm whether the installation is successful

1.4.2 install the third-party jar into maven private server

① Download Oracle jar package (omitted)

② Configure the server information of the third-party warehouse in maven's settings.xml configuration file


③ Execute the mvn deploy command to install

​ mvn deploy:deploy-file -Dfile=ojdbc14- -DartifactId=ojdbc14 –

​ Dversion= -Dpackaging=jar –

​ Durl=http://localhost:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty

Tags: Maven

Posted on Fri, 03 Dec 2021 06:39:55 -0500 by Jean-Yves