maven私服 nexus构建环境安装

Maven 是一个基于 Java 的工具,所以要做的第一件事情就是安装 JDK

Maven项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具。

下载安装

wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz

tar -xf apache-maven-3.5.4-bin.tar.gz

mv apache-maven-3.5.4 /usr/local/

添加环境变量

vim /etc/profile

export PATH=/usr/local/apache-maven-3.5.4/bin:$PATH

source /etc/profile

验证

mvn -v

配置Maven仓库

因为maven默认使用的是美国官网仓库,在速度上会很慢,所以我们要配置自己的仓库.

1 配置阿里云maven仓库

vim /usr/local/maven/conf/settings.xml

<mirror>
  <id>nexus-aliyun</id>
  <mirrorOf>*</mirrorOf>
  <name>nexus aliyun</name>
  <url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

2 创建maven私服 nexus

tar xf nexus-3.23.0-03-unix.tar.gz

mv nexus-3.23.0-03 /usr/local/
ln -s /usr/local/nexus-3.23.0-03 /usr/local/nexus

启动nexus

/usr/local/nexus/bin/nexus start

浏览器登录

192.168.2.41:8081

初始化用户名密码:

用户名  admin

密码     cat /usr/local/sonatype-work/nexus3/admin.password

配置仓库

把默认的中央仓库地址修改为阿里云maven地址

配置maven使用私服

vim /usr/local/maven/conf/settings.xml

servers标签内添加仓库认证信息 大概位置132行

<server>
  <id>release</id>
  <username>admin</username>
  <password>admin123</password>
</server>
    
<server>
  <id>snapshots</id>
  <username>admin</username>
  <password>admin123</password>
</server>

找到mirrors标签 大概170行

<mirror>
  <id>nexus</id>
  <mirrorOf>*</mirrorOf>
  <url>http://192.168.2.41:8081/repository/maven-public/</url>
</mirror>

URL私服地址获取

找到profiles标签 大概263行

<profile>
   <id>nexus</id>
<repositories>
  <repository>
    <id>central</id>
    <url>http://192.168.2.41:8081/repository/maven-public</url>
    <releases><enabled>true</enabled></releases>
    <snapshots><enabled>true</enabled></snapshots>
  </repository>
</repositories>
<pluginRepositories>
  <pluginRepository>
    <id>central</id>
    <url>http://192.168.2.41:8081/repository/maven-public</url>
    <releases><enabled>true</enabled></releases>
    <snapshots><enabled>true</enabled></snapshots>
  </pluginRepository>
</pluginRepositories>
</profile>

激活 大概292行

<activeProfiles>
    <activeProfile>nexus</activeProfile>
</activeProfiles>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值