maven的安装教程以及nexus私服配置

maven安装教程以及nexus私服配置

maven安装
1. 官方下载maven:maven官网下载地址

下载后解压的地方就是maven的安装地址
在这里插入图片描述

2. 配置环境变量

MAVEN_HOME:D:\.m2\apache-maven-3.6.3-bin\apache-maven-3.6.3(maven安装目录)
在这里插入图片描述
以管理员身份运行cmd验证是否安装成功
mvn -version在这里插入图片描述

3. 修改配置settings.xml

在这里插入图片描述
在这里插入图片描述
修改localRepository地址一般为仓库repository目录
``
D:.m2\repository

添加一句 (重点!):

<mirror> 
	<id>alimaven</id> 
	<mirrorOf>*</mirrorOf> 
	<name>aliyun maven</name>
	<url>http://maven.aliyun.com/nexus/content/repositories/central/</url> 
</mirror>

添加这句的原因是指定阿里云作为我们的中央仓库,不添加的话,默认是国外的中央仓库 (国外网速很慢很慢!)
添加了之后,我们下载东西就会快很多。

nexus私服安装(以3.28.0_01版本为例)
1. 官方下载nexus:nexus各版本下载地址

在这里插入图片描述

2. 本地环境配置

配置环境变量
NEXUS_HOME: D:\.m2\nexus-3.28.0-01-win64\nexus-3.28.0-01
PATH: %NEXUS_HOME%\bin

管理员身份运行cmd:
nexus /run
在这里插入图片描述
在这里插入图片描述
运行localhost:8081/nexus,
nexus\etc下可以修改配置
在这里插入图片描述
在这里插入图片描述
用户名admin,密码会有提示在\sonatype-work\nexus3下有admin.password文件直接把密码贴过去,然后自动修改密码

3. 文件配置

用户范围(~/.m2/settings.xml)下的settings.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>D:\.m2\repository</localRepository>
  <pluginGroups/>
  <proxies/>
  <servers/>
  <mirrors>
    <mirror>
      <id>nexus</id>
      <name>nexus maven</name>
      <url>http://localhost:8081/nexus/repository/maven-public/</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
    <mirror>
      <id>nexus-aliyun</id>
      <mirrorOf>*</mirrorOf>
      <name>Nexus aliyun</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>
    <!-- <mirror>
      <id>repo2</id>
      <mirrorOf>central</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://repo2.maven.org/maven2/</url>
    </mirror> -->
  </mirrors>
  <profiles>
    <profile>
      <id>Nexus</id>
      <repositories>
        <repository>
          <id>nexus</id>
          <url>http://localhost:8081/nexus/repository/maven-public/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>nexus</id>
          <url>http://localhost:8081/nexus/repository/maven-public/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>Nexus</activeProfile>
  </activeProfiles>
  <distributionManagement>
    <repository>
      <id>nexus-releases</id>
      <name>Nexus Release Repository</name>
      <url>http://localhost:8081/repository/maven-releases/</url>
    </repository>
    <snapshotRepository>
      <id>nexus-snapshots</id>
      <name>Nexus Snapshot Repository</name>
      <url>http://localhost:8081/repository/maven-snapshots//</url>
    </snapshotRepository>
  </distributionManagement>
</settings>


至此,maven以及私服基本配置完毕。可以编排自己所喜好的配置方式。这个配置可以做到下自动下载jar包依赖然后存储到私服中。

赠人玫瑰,手留余香。不要忘记点个赞哦

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

龙宝于

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值