nexus private server build and publish files to private server

  1. Introduction
    to Nexus Nexus is a powerful Maven repository manager that greatly simplifies the maintenance of your own internal repositories and access to external repositories; with Nexus you can fully control access and deployment in the repositories you maintain in just one place Per Artifact; Nexus is an "out of the box" system that does not require a database, it uses the file system plus Lucene to organize data; Nexus uses ExtJS to develop the interface, Restlet to provide complete REST APIs, through m2eclipse and Eclipse Integrated use; Nexus supports WebDAV and LDAP security authentication; using private server has the following benefits:
    saving external network bandwidth,
    speeding up Maven builds, and improving efficiency
    Internal deployment components
    Flexible security and rights management The
    access process is as follows:

  2. Download and install
    Official website download address:
    https://www.sonatype.com/download-oss-sonatype
    Select the corresponding version to download, I downloaded the latest nexus-3.10.0-04;
    Nexus3.x is different from Nexus2 .x is free of installation. After downloading, unzip it to the specified folder, for example: D:\nexus
    After unzipping, there will be two folders, nexus-3.10.0-04 and sonatype-work, nexus-3.10. 0-04 is the program folder, in which there is a bin folder to store the running program entry; sonatype-work is mainly the configuration/cache/storage folder;

  3. Running the Nexus service
    Open a command line and change to the Nexus program directory:

D:
cd D:\nexus\nexus-3.10.0-04\bin
nexus.exe /run

Enter nexus.exe /run to run the program:

For users who are not familiar with the command prompt operation, there is a simple way to open the command prompt window:
enter the "NEXUS_HOME\nexus\nexus-3.1.0-04\bin" directory.
Hold down the Shift key, right-click, and select "Open Command Window Here".
Enter nexus.exe /run and press Enter to run.

The process will be slow, and the following prompts will appear successfully:

Started Sonatype Nexus OSS 3.7.1-02


The default port is 8081. To modify the port, you need to modify the nexus.properties configuration file in the …\sonatype-work\nexus3\etc” directory, and modify the port in it (because the 8081 port is often occupied, there is no need to modify it if it is not occupied). )
Browser access directly enter http://localhost:8081/ , you can enter the home page: the
home page visitor identity can browse the file directory that has been downloaded to the private server, as follows:
Click on the upper right corner to log in as an administrator, the default account password is admin , admin123 :
Here you can set various warehouse configurations
of Nexus 4. Ideally, use Nexus
to return to the administrator warehouse management interface just now, copy the address of the maven-central warehouse:
then configure the pom file in the Maven project in ideal, as follows :

<repositories>
<repository>
<id>nexux</id>
<name>maven-snapshots</name>
<url>http://localhost:8081/repository/maven-central/</url>
</repository>
</repositories>

After saving, it will go to a configured Nexus private server to download,
the private server will first check whether there is a local cache, and if there is no cache, go to the central warehouse to download;

5. Publish the project to Nexus
First configure the release information in the project's pom.xml file:

<distributionManagement>
<repository>
<!--id:对应setting.xml中server id -->
<id>nexus</id>
<!--name:nexus Repository name-->
<name>maven-snapshots</name>
<!--url:nexus Repository url-->
<url>http://localhost:8081/repository/maven-snapshots/</url>
</repository>
</distributionManagement>

Then configure the server node in the settings file of the local Maven warehouse: the
settings file is in the Maven warehouse directory by default, such as: C:\Users\pact.m2\settings.xml , if not, you can create a new one

<servers>
    <server>
        <id>nexus</id>
        <username>admin</username>
        <password>admin123</password>
    </server>
</servers>
<!--mirror:nexus地址-->
<mirrors>
    <mirror>
        <!--This sends everything else to /public -->
        <id>nexus</id>
        <mirrorOf>*</mirrorOf>
        <!--这里不配置central public releases等仓库的原因 因为本地开发的时候打的版本是snapshots版本,不能直接上传到他们里面,实际开发中要是发布的版本是releases,可以配置上面的仓库 -->
        <url>http://localhost:8081/repository/maven-snapshots/</url>
    </mirror>
</mirrors>

The account must be an account that has permission to publish, otherwise it will prompt an error that cannot be authorized.
Then publish the project, run the clean deploy command, and the following output will appear and publish successfully:
Go to the web page to view, and you will find that the project just published is already in the Nexus library :

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326380660&siteId=291194637