CentOS7搭建maven私服-nexus

1,下载nexus安装包

1)直接去官网下载,链接如下:

https://www.sonatype.com/products/nexus-repository?topnav=true

2)去百度网盘拉取(此处为nexus-3.19.1-01-unix.tar.gz):

链接: https://pan.baidu.com/s/1mUPM0u-LOJSs7xH2FByOQg 提取码: bw7p

2,nexus安装

1)创建nexus组以及用户,命令如下:

[root@localhost ~]# groupadd nexus
[root@localhost ~]# useradd -g nexus -d /home/nexus -m nexus

参数说明:

-c comment 指定一段注释性描述。
-d 目录 指定用户主目录,如果此目录不存在,则同时使用-m选项,可以创建主目录。
-g 用户组 指定用户所属的用户组。
-G 用户组,用户组 指定用户所属的附加组。
-s Shell文件 指定用户的登录Shell。
-u 用户号 指定用户的用户号,如果同时有-o选项,则可以重复使用其他用户的标识号。

2)切换到nexus用户,通过文件上传工具将nexus安装包上传到nexus用户目录,并解压,操作如下:

[root@localhost ~]# su - nexus

[nexus@localhost ~]$ ls
nexus-3.19.1-01-unix.tar.gz
[nexus@localhost ~]$ tar -zxvf nexus-3.19.1-01-unix.tar.gz 

3)配置修改

进入nexus配置目录,修改项目名和端口号,命令如下:

[nexus@localhost ~]$ cd /home/nexus/nexus-3.19.1-01/etc

[nexus@localhost etc]$ vim nexus-default.properties

## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties
##
# Jetty section
#8081端口号
application-port=8081
application-host=0.0.0.0
nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
#nexus为项目名
nexus-context-path=/nexus

# Nexus section
nexus-edition=nexus-pro-edition
nexus-features=\
 nexus-pro-feature

nexus.hazelcast.discovery.isEnabled=true

4)启动nexus并查看状态,命令如下:

[nexus@localhost nexus-3.19.1-01]$ cd /home/nexus/nexus-3.19.1-01
[nexus@localhost nexus-3.19.1-01]$ ./bin/nexus start
Starting nexus
[nexus@localhost nexus-3.19.1-01]$ ./bin/nexus status
nexus is running.

5)访问nexus

浏览器输入地址,如:http://172.30.20.56:8081/nexus/

说明:172.30.20.56为部署nexus服务器ip,8081位nexus启动端口。

注意:需要关闭防火墙或者开放8081访问端口

6)修改nexus登录密码

点击登录,用户名为admin,默认密码在指定文件里面,如图:

登录完成,按提示修改密码,如图:

3,基于nexus的maven私服搭建 

用admin账号登录,依次点击Server administration and configuration-->Repository-->Repositories,界面显示如下:

 1)创建代理proxy

代理用来指向远程仓库的,如中央仓库,阿里云仓库。这里新建一个代理仓库。点击Create Repository,步骤如下:

拉到页面底端,点击Create Repository按钮,创建代理仓库完成,如下图:

 2)创建宿主host

宿主仓库管理项目打出来的包,分为发布Release和快照Snapshot两种。

创建Snapshot仓库,步骤如下:

拉到页面底端,点击Create Repository按钮,创建Snapshot仓库完成,如下图:

创建Release仓库,步骤如下:

 拉到页面底端,点击Create Repository按钮,创建Release仓库完成,如下图:

3)创建仓库组

仓库组好比数据库的视图,可以把多个仓库聚合起来用。

注:把aliyun放在maven-central上面,这样才能优先找阿里云的构件 

仓库组创建,步骤如下:

创建结果如下:

 4)nexus3.19的默认用户有两种:admin(能配置仓库、查询和上传构件)和 anonymous(只能查构件),此处为了权限可控,创建开发角色与用户(查询和上传构件)。

创建开发角色,步骤如下:

拉到最后面点击Create role按钮,创建开发角色完成,如下图:

创建开发用户,步骤如下:

开发用户创建完成,如下图:

5)sttings文件配置

<!--配置localRepository本地存储位置-->
<localRepository>/Users/dev/m2/repository</localRepository>
<!--配置servers-->
<servers>
	<server>
    <id>nexus-snapshots</id>
    <username>dev</username>
    <password>dev@ab23</password>
  </server>
  <server>
    <id>nexus-releases</id>
    <username>dev</username>
    <password>dev@ab23</password>
  </server>
</servers>
<!--配置mirrors-->
<mirrors>
	<mirror>
     <id>thirdparty</id>
     <mirrorOf>Authorized thirdparty resources by CMBC</mirrorOf>
  <name>thirdpartyMirror</name>
     <url>http://192.168.14.200:2510/nexus/repository/nexus-snapshots</url>
  </mirror>
</mirrors>
<!--配置profiles-->
<profiles>
	<profile>  
        <id>nexus</id>  
        <repositories>  
            <repository>  
                <id>snapshots</id>  
                <name>nexus snapshot repository</name>
                <url>http://192.168.14.200:2510/nexus/repository/nexus-snapshots</url>
                <releases>  
                    <enabled>true</enabled>  
                </releases>  
                <snapshots>  
                    <enabled>true</enabled>  
                </snapshots>  
            </repository>  
        </repositories>  
    </profile>
</profiles>

6)pom.xml配置

<distributionManagement>
    <snapshotRepository>
        <id>nexus-snapshots</id>
        <name>nexus snapshot repository</name>
        <url>http://192.168.14.200:2510/nexus/repository/nexus-snapshots</url>
    </snapshotRepository>
</distributionManagement>

 至此,基于nexus的maven私服搭建完成。

感谢阅读,有什么问题,欢迎各位指正。 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值