Maven私服搭建

1、下载nexus:

https://help.sonatype.com/repomanager2/download

2、上传到linux服务器scp 命令 (以私服IP是10.25.1.14为例  将这个IP改成自己的IP 下同)

  #scp nexus-2.15.1-02-bundle.tar.gz root@10.25.1.14:/usr/local/

如果有密码,输入密码即可上传

3、到linux服务器上,解压相应的文件到服务器的/usr/local文件夹下

#tar -zxvf nexus-2.15.1-02-bundle.tar.gz -C ./usr/local

4、启动

[root@localhost bin]# ./nexus start

     关闭防火墙

#systemctl stop firewalld.service

5、私服启动不了 按照提示增加配置

[root@localhost local]# cd nexus-2.15.1-02/bin/
[root@localhost bin]# ll
总用量 20
drwxr-xr-x. 15 1001 1001   272 3月  24 2022 jsw
-rwxr-xr-x.  1 1001 1001 14602 3月  24 2022 nexus
-rwxr-xr-x.  1 1001 1001  2339 3月  24 2022 nexus.bat
[root@localhost bin]# ./nexus start
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script.

修改liunx的配置

     在/etc/profile 文件中增加配置: 

        export RUN_AS_USER=root

[root@localhost bin]# source /etc/profile

6、本机访问私服

 7、登录私服 默认用户名:admin   默认密码:admin123   登录进去之后可以修改密码

 8、增加阿里云镜像

 注意地址不要写错(https://maven.aliyun.com/repository/public)

            <id>nexus-aliyun</id>
            <mirrorOf>central</mirrorOf>
            <name>Nexus aliyun</name>
            <url>https://maven.aliyun.com/repository/public</url>

 9、点击Public Repositories ->Configuration 

将新增加的阿里云移动到左侧

修改下图中的前后位置

10、增加配置文件

在settings.xml <servers>标签后加入如下两个server

  <server>
    <id>releases</id>
    <username>admin</username>
    <password>admin123</password>
  </server>
  <server>
    <id>snapshots</id>
    <username>admin</username>
    <password>admin123</password>
  </server>
增加mirror
    <mirror>
      <id>nexus</id>
      <mirrorOf>central</mirrorOf>
      <name>my nexus</name>
      <url>http://10.25.1.14:8081/nexus/content/groups/public/</url>
    </mirror>
父pom中增加
<distributionManagement>
    <repository>
        <id>releases</id>
        <name>releases Repository</name>
        <url>http://10.25.1.14:8081/nexus/content/repositories/releases/</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>snapshots Repository</name>
        <url>http://10.25.1.14:8081/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>
</distributionManagement>

本地pom增加

<repositories>
    <repository>
        <id>public</id>
        <name>maven-public</name>
        <url>http://10.25.1.14:8081/nexus/content/groups/public/</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <releases>
            <enabled>true</enabled>
        </releases>
    </repository>
</repositories>

done......

如果对你有帮助,欢迎大家点赞收藏,谢谢!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值