Nexus Repository Manager application

Nexus Repository Manager installation and operation is very simple. You can archive files to the directory where you have full access, you can also use the Docker image to install it.

Download the installation package: https://help.sonatype.com/repomanager3/download
installation reference documentation: https://help.sonatype.com/repomanager3

1, download the installation package
https://help.sonatype.com/repomanager3/download/download-archives---repository-manager-3

wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz

Nexus Repository Manager application

2, extract

tar xvzf nexus-3.19.1-01-unix.tar.gz

Nexus Repository Manager application

3, to modify the default configuration file (etc / nexus-default.properties) [optional]
Nexus Repository Manager application
here is mainly used to modify the port number

4, change the default configuration (bin / nexus.vmoptions) [optional]
Nexus Repository Manager application
generally do not need modification.

5, modify the configuration jdk [optional]
can edit the bin / nexus script, find the "INSTALL4J_JAVA_HOME_OVERRIDE", removing hash and specify the JDK / JRE location.
Nexus Repository Manager application
E.g:

INSTALL4J_JAVA_HOME_OVERRIDE=/usr/lib/jvm/openjdk-8

6, start

./nexus run

Run in the current shell will run using the nexus. It may also be used start, stop, restart, force-reload, and status commands.
Nexus Repository Manager application

7, visit
Nexus Repository Manager application

Nexus Repository Manager application
Login password file /data/sonatype/sonatype-work/nexus3/admin.password in.
Nexus Repository Manager application
Nexus Repository Manager application
Nexus Repository Manager application
Nexus Repository Manager application
By default, anonymous access is enabled to allow unauthenticated download, browse and search content repositories. You can change the permissions unauthenticated user to the anonymous user's role by editing assignment.

Nexus Repository Manager application

Nexus Repository Manager application

Column Type Description:
1) Proxy
default to create a central repository accessible via HTTPS ( https://repo1.maven.org/maven2/) proxy repository. All other remote repositories order to reduce duplication and increase download speed download developers and CI server should also be accessible to the agent for the agent repository .

2) Hosted
Hosted Maven Repository can be used to deploy their own components and third-party components. By default, created two hosted Maven repository, are maven-releases and maven-snapshots. A strategy for the release version, a version of a policy for a snapshot.

3) group
repository group allows you to use a URL polymerization disclosure of multiple agents and hosts the repository and other repositories group for the tool configuration. We recommend the use of library groups all the Maven repository from the Repository Manager open to the user, without further client configuration.

8, warehouse operations

Nexus Repository Manager application

Nexus Repository Manager application

Nexus Repository Manager application

9, Maven used
1) Maven editor of setting.xml file

<settings>
  <mirrors>
            <!—配置一个镜像用于替代中央仓库 -->
            <mirror>
                <id>nexus</id>
                <name>nexus</name>
                <url>http://192.168.30.161:8081/repository/maven-public/</url>
                <mirrorOf>*</mirrorOf> 
            </mirror>
  </mirrors>
  <servers>
            <server>
                <id>nexus</id>
                <username>admin</username>
                <password>123456</password>
            </server>
            <server>
                <id>realeases</id>
                <username>admin</username>
                <password>123456</password>
            </server>
            <server>
                <id>snapshots</id>
                <username>admin</username>
                <password>123456</password>
            </server>
  </servers>
</settings>

2) pom.xml file in the project editor

    <!-- 远程仓库地址 -->
    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>Team Nexus Repository</name>
            <url>http://192.168.30.161:8081/repository/maven-public/</url>
        </pluginRepository>
    </pluginRepositories>
   <!-- 配置远程发布到私服,mvn deploy -->
    <distributionManagement>
        <!-- 定义releases库的坐标 -->
        <repository>
            <id>releases</id>
            <name>Nexus Release Repository</name>
            <url>http://192.168.30.161:8081/repository/maven-releases/</url>
        </repository>
        <!-- 定义snapshots库 -->
        <snapshotRepository>
            <id>snapshots</id>
            <name>Nexus Snapshot Repository</name>
            <url>http://192.168.30.161:8081/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

Plug

<!-- deploy时只上传jar包到远程仓库的配置 -->
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.7</version>
                 <configuration>
                                    <!-- 更新元数据 -->
                                    <updateReleaseInfo>true</updateReleaseInfo>
                                </configuration>
                <executions>
                    <execution>
                        <id>default-deploy</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                        <!-- skip默认deploy插件的执行 -->
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>deploy-file</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy-file</goal>
                        </goals>
                        <configuration>
                            <!-- 开发阶段上传到snapshot仓库,上线阶段上传到release仓库 -->
                            <repositoryId>${project.distributionManagement.snapshotRepository.id}</repositoryId>
                            <url>${project.distributionManagement.snapshotRepository.url}</url>
                            <file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>${project.artifactId}</artifactId>
                            <version>${project.version}</version>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Thus, by mvm deploy jar package can be uploaded to PW warehouse.

Guess you like

Origin blog.51cto.com/dengshuangfu/2454961