添加角色

 

 

添加本地jar到私有仓库

 

上传完成后可以在这查看

 

 

 Jar包更新

Nexus可以自动更新网络上存在的jar包的索引,但是提供更新索引的网站是外国的,所以下载速度特别!特别!特别的慢!!!!不建议使用

然后Nexus就会自动开始慢的可怜的更新了
可以在这查看慢的可怜的更新情况,包括取消更新也慢的可怜

 

手动更新
手动更新需要下载好的索引,以及导入索引的配置文件和jar文件

链接: https://pan.baidu.com/s/1fwwq32Rjn3IzpjIMZKHvcQ
提取码: nxs2

下载完成后将三个文件拷到linux系统下,然后使用指令生成索引文件
java -jar indexer-cli-5.1.0.jar -u nexus-maven-repository-index.gz -d indexer
解压完成后的大小indexer

 

进入到nexus存储空间中,删除旧的索引
/usr/local/src/sonatype-work/nexus/indexer/central-ctx

 rm *

 

然后进到刚才解压出来的indexer文件中,将全部文件复制到刚才的目录下
路径根据自己的实际情况适当修改
[root@nexus ~]# cd indexer
[root@nexus indexer]# ls
_4j.fdt _4j.fdx _4j.fnm _4j.frq _4j.nrm _4j.prx _4j.tii _4j.tis segments_2 segments.gen timestamp
[root@nexus indexer]# cp -r * /usr/local/src/sonatype-work/nexus/indexer/central-ctx/

 

完成后没有提示信息,如果现实是否覆盖,那就是你前面没删干净
启动Nexus
[root@nexus ~]# cd /usr/local/src/nexus-2.14.14-01
[root@nexus nexus-2.14.14-01]# cd bin
[root@nexus bin]# ./nexus start

这样索引就出现了

 

 

 配置本地项目引用私服

在工程pom.xml中添加

<distributionManagement>
<repository>
<id>releases</id>
<url>http://192.168.103.16:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168. 103.16:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

修改本地$MAVEN_HOME\conf目录下的settings.xml配置文件,添加如下配置\

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

在本地工程目录下执行:
mvn deploy
所部署的包就自动上传到了nexus安装目录下的

配置Maven从Nexus下载构件

在POM中配置Nexus私服,这样的配置只对当前的Maven项目有效。
<!--指定Nexus的构件仓库-->
<repositories>
<repository>
<id>public</id>
<name>Team Maven Repository</name>
<url>http://192.168. 103.16:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<!--指定Nexus的插件仓库-->
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>Team Maven Repository</name>
<url>http://192.168. 103.16:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

在settings.xml中配置profile元素,这样就能让本机所有的Maven项目都使用自己的Maven私服
<properties>
<repository>
<id>public</id>
<name>Team Maven Repository</name>
<url>http://192.168.103.16:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<br>
</properties>