Maven的原理就是将jar从远程中央仓库下载到PC磁盘的本地仓库,当本地仓库没有发现须要的jar就会去Maven默认的远程中央仓库Maven Central(由Apache维护)中寻找,每次须要新的jar后都要从远程中央仓库上下载。那么问题来了?这个远程的中央仓库必定有不少人使用那下载速度必定很慢,这个暂且不用考虑。 重要的是万一哪天公司外网连不上了咋办?而Nexus私服刚好能够解决这个问题。搭建私服的好处是Nexus有效解决了Maven对Apache的远程中央仓库的依赖,当项目须要新的jar时会先在nexus私服下载好之后才会下载到本地。若是发现私服已经存在这个jar包,则会直接从私服下载到本地Maven库,若是没有再去网络上下载。同时,咱们也可打包本身的代码变成jar包上传到私服中供公司其余同事下载使用。apache
tar -zvxf nexus-3.13.0-01-unix.tar.gz -C /opt/
复制代码
vim /opt/nexus-3.13.0-01/bin/nexus
//配置JDK 路径
INSTALL4J_JAVA_HOME_OVERRIDE=/opt/jdk1.8.0_181
复制代码
/opt/nexus-3.13.0-01/bin/nexus start
复制代码
//加入9190端口的监听
vim /etc/sysconfig/iptables
查看是否监听端口(若是配置了本身定义的端口,须要先访问该端口一次才能看到监听)
netstat -ntlp
//重启防火墙配置(不重启端口仍是没法生效)
service iptables restart
//修改端口号
vim /opt/nexus-3.13.0-01/etc/nexus-default.properties
//重启Nexus
/opt/nexus-3.13.0-01/bin/nexus restart
Nexus其余命令
//中止
nexus stop
//查看状态
nexus status
默认登陆用户名密码
admin
admin123
卸载
rm -rf nexus-3.13删除掉安装目录便可
//能够看到Nexus在浏览器中能够打开界面,部署成功,以下图
复制代码
<repositories>
<repository>
<id>nexus</id> <!--id要和上一步配置的id一致-->
<name>local nexus</name>
<url>http://xxxxx:9190/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>local nexus</name>
<url>http://xxxxx:9190/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
复制代码
1.group(仓库组类型):又叫组仓库,用于方便开发人员本身设定的仓库;
2.hosted(宿主类型):内部项目的发布仓库(内部开发人员,发布上去存放的仓库)
3.proxy(代理类型):从远程中央仓库中寻找数据的仓库(能够点击对应的仓库的 Configuration 页签下 Remote Storage Location 属性的值即被代理的远程仓库的路径)
复制代码
到此,Nexus搭建Maven私服服务已经完成.vim