使用Nexus(3.7.1)建立Maven仓库私服

本文介绍如何通过Nexus搭建Maven私服,包括启动Nexus服务、登录配置、修改settting.xml文件、配置pom.xml文件等步骤,帮助开发者实现本地化的依赖管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、在Nexus的bin目录下shift+右键-打开命令窗口,输入nexus /run (或者使用nexus /start)开启nexus服务

(直接打开nexus.exe无法启动)

image

服务启动完成后效果如下

image

2、登录nuxes服务器,默认地址和端口为http://localhost:8081/

image

点击sign in 登录。默认的用户名和密码为admin/ admin123

点击配置图标(齿轮),点击Repositories可以以查看当前的仓库配置,我们这里使用默认配置。

image

 

3、配置maven的settting.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>F:\maven\repository</localRepository>

<pluginGroups></pluginGroups>
<proxies></proxies>

<!--server中添加nexus的用户名和密码-->
<servers>
    <server>
      <id>nexus</id>
      <username>admin</username>
      <password>admin123</password>
    </server>

  </servers>

<!--mirror中添加nexus的访问路径-->
<mirrors>
     <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>
http://localhost:8081/repository/maven-public/</url>
    </mirror>

</mirrors>

<!--profile中添加nexus的两个仓库设置-->
  <profiles>
   <profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <id>maven-public</id>
          <url>
http://localhost:8081/repository/maven-public/</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>maven-public</id>
          <url>
http://localhost:8081/repository/maven-public/</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>

  </profiles>

<!--是能nexus的profile-->
<activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

</settings>

 

4、设置maven项目的pom.xml文件

在添加

<distributionManagement>
  <repository>
    <id>nexus</id>
    <name>Releases</name>
    <url>http://localhost:8081/repository/maven-releases</url>
  </repository>
  <snapshotRepository>
    <id>nexus</id>
    <name>Snapshot</name>
    <url>http://localhost:8081/repository/maven-snapshots</url>
  </snapshotRepository>
</distributionManagement>

image

5、下载的jar默认保存路径为nexus-3.7.1-02-win64\nexus-3.7.1-02\system,完成以上步骤后可以通过这里查看是否已下载jar包,或者在web界面查看

image

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值