Nexus best practice configuration

nexus warehouse type

There are four types of warehouses:

  1. group: warehouse group
  2. hosted: host
  3. proxy: proxy
  4. virtual: virtual

Warehouse group

For external use, directly use the warehouse group for external use.

Such as: http: // [private service IP]: 8082 / nexus / content / groups / public /

Pay attention to the order of the warehouse group, generally the company first, then the third party, then the central warehouse.

  1. Releases: The host type repository used to deploy and manage the release version components within the company
  2. Snapshots: Host type repository used to deploy and manage snapshot version components within the company
  3. 3rd party: A third-party release version of the component warehouse that cannot be obtained from the public warehouse (SMS SDK, etc.)
  4. Central: the warehouse used to proxy the release version components in the maven central warehouse

Best use:
Insert picture description here

Settings.xml configuration under .m2

<?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">

  <localRepository>/Users/jeikerxiao/.m2/repository</localRepository>

  <servers>
    <!-- 私服仓库账号和密码,用于部署使用 -->
    <server>
      <id>nexus-releases</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
    <server>
      <id>nexus-snapshots</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>
  <!-- 所有请求远程仓库都走私服 -->
  <mirrors>
    <mirror>
      <id>nexus-releases</id>
      <mirrorOf>*</mirrorOf>
      <url>http://[私服IP]:8082/nexus/content/groups/public</url>
    </mirror>
    <mirror>
      <id>nexus-snapshots</id>
      <mirrorOf>*</mirrorOf>
      <url>http://[私服IP]:8082/nexus/content/repositories/snapshots</url>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <id>nexus-releases</id>
          <url>http://nexus-releases</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
        <repository>
          <id>nexus-snapshots</id>
          <url>http://nexus-snapshots</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>nexus-releases</id>
          <url>http://nexus-releases</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
        <pluginRepository>
          <id>nexus-snapshots</id>
          <url>http://nexus-snapshots</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

</settings>

Pom.xml configuration of maven project

<distributionManagement>  
        <!-- 两个ID必须与 setting.xml中的<server><id>nexus-releases</id></server>保持一致-->  
        <repository>  
            <id>nexus-releases</id>  
            <name>Nexus Release Repository</name>
            <url>http://[私服IP]:8082/nexus/content/repositories/releases</url>  
        </repository>  
        <snapshotRepository>  
            <id>nexus-snapshots</id>  
            <name>Nexus Snapshot Repository</name>  
            <url>http://[私服IP]:8082/nexus/content/repositories/snapshots</url>  
        </snapshotRepository>  
</distributionManagement>
Published 420 original articles · 143 thumbs up · 890,000 views

Guess you like

Origin blog.csdn.net/jeikerxiao/article/details/95045416