- 1. Nexus安装
- 1.1 安装要求
- 1.2 下载并解压
- 1.3 修改etc/nexus-default.properties
- 1.4 启动nexus
- 1.5 查看端口占用情况
- 1.6 访问Nexus首页
- 2. Nexus的使用
- 2.1 Nexus各种仓库的作用
- 2.2 settings.xml配置使用Nexus public仓库
- 2.3 配置Nexus的maven-central从阿里云仓库下载进行
- 2.4 从Nexus public仓库下载jar包
- 2.5 将jar包部署到Nexus
- 2.6 引用Nexus snapshots仓库的jar包
需要先安装好JDK8
1.2 下载并解压OSS版本的可以下载免费使用,下载地址为:https://help.sonatype.com/repomanager3/product-information/download,这里我们下载目前的最新版:https://download.sonatype.com/nexus/3/nexus-3.40.1-01-unix.tar.gz
[root@bigdata001 ~]# wget https://download.sonatype.com/nexus/3/nexus-3.40.1-01-unix.tar.gz
[root@bigdata001 ~]#
[root@bigdata001 ~]# tar -zxvf nexus-3.40.1-01-unix.tar.gz
[root@bigdata001 ~]#
[root@bigdata001 ~]# cd nexus-3.40.1-01
[root@bigdata001 nexus-3.40.1-01]#
1.3 修改etc/nexus-default.properties
修改内容如下:
application-port=9999
1.4 启动nexus
[root@bigdata001 nexus-3.40.1-01]# bin/nexus start
WARNING: ************************************************************
WARNING: Detected execution as "root" user. This is NOT recommended!
WARNING: ************************************************************
Starting nexus
[root@bigdata001 nexus-3.40.1-01]#
[root@bigdata001 nexus-3.40.1-01]# bin/nexus status
WARNING: ************************************************************
WARNING: Detected execution as "root" user. This is NOT recommended!
WARNING: ************************************************************
nexus is running.
[root@bigdata001 nexus-3.40.1-01]#
1.5 查看端口占用情况
[root@bigdata001 nexus-3.40.1-01]# netstat -nltp | grep 9999
tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN 20675/java
[root@bigdata001 nexus-3.40.1-01]#
1.6 访问Nexus首页
访问:http://bigdata001:9999。如下所示
然后点击sign in进行登录,根据提示输入用户名和密码进行登录。如下所示
然后进行新密码的输入,选择取消匿名访问。到这里就完成了登录操作
将mirror配置的阿里云仓库
alimaven
aliyun maven
central
https://maven.aliyun.com/repository/central
修改成Nexus的public仓库
nexus-maven
nexus-maven
central
http://192.168.8.111:9999/repository/maven-public
然后在settings.xml种配置Nexus服务的用户名和密码,以便能够下载jar包
nexus-maven
admin
admin123
2.3 配置Nexus的maven-central从阿里云仓库下载进行
最后点击Save保存即可
下载jar包会以本地仓库、Nexus public仓库、Maven中央仓库的顺序进行下载
然后执行如下命令。-U
参数表示强制进行依赖更新
C:\Users\dell\Desktop\maven-learn>mvn clean compile -U
然后查看maven-public仓库,是有依赖的
配置project的pom.xml。添加jar包分发的仓库地址。完整的pom.xml内容如下:
4.0.0
com.hh
maven-learn
0.1-SNAPSHOT
nexus-maven
Nexus Snapshot
http://192.168.8.115:9999/repository/maven-snapshots
然后执行如下命令,进行部署
C:\Users\dell\Desktop\maven-learn>mvn clean deploy
可以看到已经部署到Nexus的snapshots仓库了
新建一个project,名称为maven-learn2。添加Nexus snapshots仓库的地址和jar包的依赖到pom.xml。完整的pom.xml文件内容如下:
4.0.0
com.hh
maven-learn2
0.1
nexus-maven
Nexus Snapshot
http://192.168.8.115:9999/repository/maven-snapshots
true
false
com.hh
maven-learn
0.1-SNAPSHOT
然后就可以引用maven-learn这个依赖包的程序了