12 PW build maven nexus

Distribution management company for the convenience of the jar package jar package and their own projects, will build a maven PW. Employees can be downloaded from the jar package PW, when a jar if the package does not exist on the PW, maven PW go public warehouse download, in fact, played a reverse proxy role. This article explains how to set up maven PW nexus.

1, environmental constraints

  • win10
  • nexus-2.12.0-01
  • maven-3.0.5

2, the premise of restraint

  • Deployment maven-3.0.5 has been
    assumed that the author maven path is C: \ Program Files \ maven- 3.0.5
    hypothesis of a local warehouse is located in C: \ Users \ zhangli.m2

2, Procedure

2.1 set up and start nexus Services

  • Download Nexus
    Nexus official website addresses
    Select windows version select windows version
    of the version here is nexus-2.12.0-01
  • Decompression, is assumed to extract the folder D: / soft
    Unzip to D: / softextract to D: / soft
  • Administrator, open a command line, execute the following command
# 进到D盘
D:
# 进入nexus解压目录
cd D:\soft\nexus-2.12.0-01\bin
# 安装nexus
nexus.bat install
# 启动nexus
nexus.bat start
  • Check your operating system services
    nexus web is runningnexus web is running
  • Access HTTP: // localhost: 8081 / Nexus /
    [Nexus Home] (https://upload-images.jianshu.io/upload_images/16204070-7407bea38424c3ed.png?imageMogr2/auto-orient/strip%7CimageView2!
    / 2 / w / 1240)
  • Login
    Click LoginClick Login
    Enter the default username and passwordEnter the default username and password

2.2 upload jar package to PW

  • Modification C: \ Users \ zhangli.m2 \ settings.xml, increasing nexus server node disposed in the servers
* 将Apache SnapShots与其他节点加为同一组
![图片.png](https://upload-images.jianshu.io/upload_images/16204070-4b4d1f0cd59e301f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

    <server>
        <id>releases</id>
        <username>admin</username>
        <password>admin123</password>
    </server>
    <server>
        <id>snapshots</id>
        <username>admin</username>
        <password>admin123</password>
    </server>   

Pictures .pngPictures .png

  • Create a maven project, named nexusdemo
    https://www.jianshu.com/p/042073b7710b
    Suppose you create project information as follows:
    <groupId>net.wanho.nexus</groupId>
    <artifactId>nexus-demo</artifactId>
    <version>1.0-SNAPSHOT</version>
  • The modified nexusdemo pom.xml, add the following node in the project below:
    <distributionManagement>
        <repository>
            <id>releases</id>
            <url>http://localhost:8081/nexus/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
  • install nexusdemo project
    in C: \ Users \ zhangli.m2 \ repository \ net \ wanho \ nexus \ nexusdemo \ 1.0-SNAPSHOT path below the nexusdemo-1.0-SNAPSHOT jar package and a corresponding mounting pom
  • deploy nexusdemo project
    in D: \ soft \ sonatype-work \ nexus \ storage \ snapshots \ net \ wanho \ nexus \ nexusdemo \ path with the 1.0-SNAPSHOT nexusdemo-1.0-SNAPSHOT jar and its corresponding packet pom

Download jar package from PW

  • Create a maven project, named nexus-use-jar
  • Add the following dependence in the project:
<dependency>
    <groupId>net.wanho.nexus</groupId>
    <artifactId>nexus-demo</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>

At this time, the package is introduced into the jar no problem, because it comes from .m2;

  • Modify pom.xml nexus-use-jar, adding the following at the project node:
   <repositories>
        <repository>
            <id>abc</id>
            <url>http://localhost:8081/nexus/content/groups/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>abc</id>
            <url>http://localhost:8081/nexus/content/groups/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
        </pluginRepository>
    </pluginRepositories>
    • The Apache Snapshots and other configuration applied to the same set of
      Click saveclicks save
      the following results
      Added to the same groupadded to the same group
    • Delete the C: \ Users \ zhangli.m2 \ repository \ \ wanho \ nexus folder net
      this time, nexus-use-jar project is dependent error, but later reimport the project, just delete the jar package again downloaded to the C: \ Users \ zhangli.m2 \ repository \ net \ wanho \ nexus folder. Obviously we do not have to re-install, the jar package is automatically downloaded from the PW.
      These are the nexus PW maven jar package to build and upload and download process.

Guess you like

Origin www.cnblogs.com/alichengxuyuan/p/12581838.html