Nexus Repository Manager的运用

设备和作业Nexus Repository Manager很简单。您可以将存档文件解压缩到您有彻底拜访权限的目录中,也可以正常的运用Docker映像设备它。

设备包下载:https://help.sonatype.com/repomanager3/download
设备参看文档:https://help.sonatype.com/repomanager3

1, 下载设备包
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的运用

2, 解压

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

Nexus Repository Manager的运用

3, 修改默许的装备文件(etc/nexus-default.properties) 【可选】
Nexus Repository Manager的运用
这儿大多数都用在修改端口号

4, 修改默许装备(bin/nexus.vmoptions)【可选】
Nexus Repository Manager的运用
正常的情况下是不需要修改的。

5, 修改jdk装备【可选】
可以批改bin/nexus脚本,找到“INSTALL4J_JAVA_HOME_OVERRIDE”,删去哈希并指定JDK/JRE的方位。
Nexus Repository Manager的运用
例如:

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

6, 主张

./nexus run

运用run会使nexus在当时shell中作业。也可以正常的运用start, stop, restart, force-reload 和status 指令。
Nexus Repository Manager的运用

7,拜访
Nexus Repository Manager的运用

Nexus Repository Manager的运用
登录暗码在文件/data/sonatype/sonatype-work/nexus3/admin.password中。
Nexus Repository Manager的运用
Nexus Repository Manager的运用
Nexus Repository Manager的运用
Nexus Repository Manager的运用
默许情况下,启用匿名拜访将容许未经身份验证的下载、阅读和查找存储库内容。可以究竟靠批改分配给匿名用户的人物来更改未经身份验证用户的权限。

Nexus Repository Manager的运用

Nexus Repository Manager的运用

Type列阐明:
1) Proxy
默许创建了一个经过HTTPS拜访中心库房(https://repo1.maven.org/maven2/)的署理存储库。为了削减重复下载并行进开发人员和CI服务器的下载速度,还应该将拜访的悉数其他长途存储库署理为署理存储库。

2) hosted
hosted Maven repository可用于安顿自己的组件和第三方组件。默许情况下,创建了两个hosted Maven库,分别是maven-releases与maven-snapshots。一个用于发布版别战略,一个用于快照版别战略。

3) group
存储库组容许您运用一个URL戳穿多个署理和保管存储库以及其他存储库组的聚合内容以进行东西装备。主张运用存储库组将悉数Maven存储库从存储库管理器戳穿给用户,而无需进一步的客户端装备。

8,库房的操作

Nexus Repository Manager的运用

Nexus Repository Manager的运用

Nexus Repository Manager的运用

9,Maven中运用
1)批改Maven的setting.xml文件

<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文件

    <!-- 长途库房地址 -->
<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>

插件

<!-- 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>

如此,经过mvm deploy就可以将jar包上传到私服库房下。