maven、nexus 私服搭建与核心功能

1、私服使用场景

私服使用场景如下:

1、公司不能连接公网,可以用一个私服务来统一连接

2、公司内部jar 组件的共享

 

2、nexus 下载安装

nexus 下载地址:

https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.14.5-02-bundle.tar.gz

解压并设置环境变量

#解压

shell>tar -zxvf nexus-2.14.5-02-bundle.tar.gz

扫描二维码关注公众号,回复: 9966875 查看本文章

#在环境变量当中设置启动用户

shell> vim /etc/profile

需要加相应权限

export RUN_AS_USER=root

 

#进入解压的目录

#启动与停止nexus

#启动

shell>  /bin/nexus start

#停止

shell>  /bin/nexus stop

启动后访问:服务器地址:8081,默认端口8081

默认账号:

 admin/admin123

 deployment/deployment123

3、nexus 仓库介绍

3rd party:第三方仓库

Apache Snapshots:apache 快照仓库

Central: maven 中央仓库

Releases:私有发布版本仓库

Snapshots:私有 快照版本仓库

 

4 、本地远程仓库配置

或者在settings.xml 文件中配置远程仓库镜像 效果一样,但作用范围广了

<mirror>       

        <id>nexus-aliyun</id>

        <mirrorOf>*</mirrorOf>

        <name>Nexus aliyun</name>

       <url>http://192.168.0.147:8081/nexus/content/groups/public/</url>

</mirror>

添加用户

<server>

      <id>nexus-snapshot</id>

      <username>deployment</username>

      <password>deployment123</password>

    </server>

 

5、上传jar包

mvn deploy:deploy-file -DgroupId=com.fasterxml.jackson.core -DartifactId=jackson-databind -Dversion=2.5.0 -Dpackaging=jar -Dfile=jackson-annotations-2.5.0.jar -Durl=http://192.168.0.141:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=nexus-snapshot

DgroupId、DartifactId、Dversion:构成了该jar包在pom.xml的坐标,自己起名字也是可以的. 
Dpackaging:表示打包类型. 
Dfile:表示需要上传的jar包的绝对路径. 
Durl:私服上第三方仓库的地址,打开nexus——>repositories菜单,可以看到该路径。 
DrepositoryId:服务器的表示id,就是我们在setting.xml文件中配置的serverId。

执行成功表示已经上传到Nexus私服了.

之后,项目组成员,只要在修改maven的setting.xml,添加私服的地址,就可以正常使用私服的jar包了

 

 

发布了19 篇原创文章 · 获赞 5 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/weixin_42165041/article/details/82258574