To learn more about how to install the Nexus3 for Linux, see the official documentation. Here is how to install and configure the docker method.

Install the Nexus

  • Search nexus Images

  • Pull the mirror

    docker pull sonatype/nexus3
    Copy the code
  • Check whether the mirror is pulled down

  • Create a mount address for the Nexus and authorize it

    Create mount address
    mkdir /usr/local/nexus
    # authorize the folder
    chmod chmod -R 777 /usr/local/nexus 
    Run the Nexus in the background and mount it
    docker run -d -p 8081:8081 --name nexus3 -v /usr/local/nexus:/nexus-data sonatype/nexus3
    Copy the code
  • Access Nexus (default account: admin, password in admin.password file)

Configure the nexus

  • These repositories exist by default, so you can use them directly or modify them. In order to configure our own warehouse we need to delete the own warehouse.

  • Blob Stores Introduction Repositor is required to be stored in Blob format. The default Blol Stores are file system-based, which you can think of as a directory

    Blob Store: Blob Store: Blob Store: Blob Store: Blob Store: Blob Store: Blob Store: Blob Store: Blob Store: Blob Store: Blob Store

    Blob Stores parameters are as follows:

    parameter meaning
    Name The Blob Stores name is unique
    Type Type, usually File
    State state
    Blob count The number of blobs
    Total size Now the size of the directory to store
    Available space The available space is the remaining disk space of the partition where the directory is stored
  • Creating a Blob Store Go to Repository > Blob Store > Create Blob Store

    • Type: the haveFileandS3Two choices, File will do.
    • -Leonard: Name is my Nameaen-blob
    • Enable Soft Quota: This limits the directory size. There’s no limit here. If you have a limit, just tick and fill in the condition of the upper limit and the value of the limit.
    • Path: is a Path that is automatically generated when you fill in Name

    Finally clickCreate blob storeIt’s good

  • Create a Hosted type repository

    This repository mainly put some of their own packaged tool classes, their own manual build uploaded packages, or the central repository can not find packages

    Hosted has two types of Maven repositories: Snapshot and Release. How do you distinguish between them?

    Snapshot: a library that is unstable and can be modified several times a day.

    It was released. So this tends to be a more stable distribution

  • Go to Repository > Repositories > Create Repository and select Maven2 (Hosted).

    • Name: Whatever you want to call it, Maven-Release-aen

    • Online: Check to set whether the repository is Online or offline

    • Maven2:

      Version Policy: indicates the Version Policy. The options are as follows: Release: indicates the official Version. Snapshot: indicates the Snapshot Version.

      Layout Policy Strict Permissive The default is Strict.

    • Storage: Blob Store: Select the Blob store used by this repository, in this case the aen-blob created earlier. Strict Content Type Validation: verifies the format of the uploaded Content. This parameter is not selected.

    • Hosted:

      Deployment Policy: Deployment Policy. The options are as follows: Allow Redeploy: allows redeployment. Disable Redeploy: disables redeployment

      Because this is the release library, Disable Redeploy is selected.

  • To Create the Snapshot library, go to Repository > Repositories > Create Repository and select Maven2 (Hosted).

  • To Create a Repository of proxy type, go to Repository > Repositories > Create Repository and select Maven2 (Proxy).

    • Proxy: maven.aliyun.com/nexus/conte…
    • If you look at the image above, everything else is the default
  • To Create a Repository of group type go to Repository > Repositories > Create Repository and select Maven2 (Gruop).

It is recommended that ali Cloud’s agent repository be placed first in the group order, because maven’s agent repository is downloaded from top to bottom. It is recommended that the fast repository be placed first.

Verification test

  • Pretend that you all have JDK and Maven environments, and change the Settings in Maven such as my D:\apache\apache-maven-3.5.4\conf\settings.xml. Remember to back up this file or you’ll be in trouble if you make a mistake.

    <?xml version="1.0" encoding="UTF-8"? >
    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
        <! -- Local warehouse address -->
        <localRepository>D:\m2\repository</localRepository>
     
    	<pluginGroups>
    	
    	</pluginGroups>
      
    	<proxies>
    	
    	</proxies>
      
    	<servers>
    		<server>
    			<id>nexus-aen</id>
    			<username>admin</username>
    			<password>Nexus2020</password>
    		</server>
    		<server>
    			<id>releases</id>
    			<username>admin</username>
    			<password>Nexus2020</password>
    		</server>
    		<server>
    			<id>snapshots</id>
    			<username>admin</username>
    			<password>Nexus2020</password>
    		</server>
    	</servers>
      
    	<mirrors>
    	   <mirror>
    	   	<id>nexus-aen</id>
    	      <name>internal nexus repository</name>
    	      <! -- Mirror uses the configured group address -->
    	      <url>http://192.168.31.236:8081/repository/maven-public-aen/</url>
    	      <mirrorOf>! internal.repo,*</mirrorOf>
    	   </mirror>
    	</mirrors>
      
    	<profiles>
    	   <profile>
    			  <! --ID identifies the unique identity of the profile -->
    	          <id>JDK - 1.8 -</id>
    	          <activation>
    	              <activeByDefault>true</activeByDefault>
    	              <jdk>1.8</jdk>
    	          </activation>
    	          <properties>
    	              <maven.compiler.source>1.8</maven.compiler.source>
    	              <maven.compiler.target>1.8</maven.compiler.target>
    	              <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
    	          </properties>
    	  </profile>
    	
    	  <profile>
    	  <id>nexus-pro</id>
    	   <! -- Remote repository list -->
    	  <repositories>
    		<repository>
    		  <id>nexus</id>
    		  <name>Nexus Central</name>
    		 <! -- virtual URL form, pointing to the image URL-->
    		  <url>http://192.168.31.236:8081/repository/maven-public-aen/</url>
    		  <layout>default</layout>
    		 <! Releases the releases version from this repository.  
    		  <releases>
    			<enabled>false</enabled>
    			<updatePolicy>always</updatePolicy>
    		  </releases>
    		 <! -- Indicates that the snapshot version of the component can be downloaded from this repository -->  
    		  <snapshots>
    			<enabled>true</enabled>
    			<updatePolicy>always</updatePolicy>
    		  </snapshots>
    		</repository>
    	  </repositories>
    	  
    	   <! -- Plugin repository list -->
    	  <pluginRepositories>
    		<pluginRepository>
    		  <id>nexus</id>
    		  <name>Nexus Central</name>
    		  <url>http://192.168.31.236:8081/repository/maven-public-aen/</url>
    		  <layout>default</layout>
    		  <snapshots>
    			<enabled>true</enabled>
    			<updatePolicy>always</updatePolicy>
    		  </snapshots>
    		  <releases>
    			 <enabled>true</enabled>
    			 <updatePolicy>always</updatePolicy>
    		  </releases>
    		</pluginRepository>
    	  </pluginRepositories>
    	</profile>
    	 </profiles>
    
      <activeProfiles>
      	<activeProfile>nexus-pro</activeProfile>
      	<activeProfile>JDK - 1.8 -</activeProfile>
      </activeProfiles>
    </settings>
    Copy the code
  • Add the distributionManagement attribute to the POM file that you want to package

     <! Use distribution management to jar the project and upload it directly to the specified server.
     <distributionManagement>
         <! -- Official version -->
         <repository>
             <! -- Nexus server user name: <server> id in settings. XML
             <id>releases</id>
             <! -- this name is self-defined -->
             <name>Release repository</name>
             <url>http://192.168.31.236:8081/repository/maven-releases-aen/</url>
         </repository>
         <! Snapshot -- -- -- >
         <snapshotRepository>
             <! -- Nexus server user name: <server> id in settings. XML
             <id>snapshots</id>
             <! -- this name is self-defined -->
             <name>Snapshots repository</name>
             <url>http://192.168.31.236:8081/repository/maven-snapshots-aen/</url>
         </snapshotRepository>
     </distributionManagement>
    Copy the code
  • Let’s take a look at the Maven-public-aen and Maven-Release-aen libraries before packing up and uploading

  • Packing is just a matter of ordering

  • Now let’s look at the Maven-public-aen and Maven-Release-aen libraries again

Well here is our Maven repository set up test completed

Reference Address:

Help.sonatype.com/repomanager… Hub.docker.com/r/sonatype/… Blog.csdn.net/wc169504084…