本地Maven结合Nexus的使用

仓库的类型

在这里插入图片描述

  • proxy:代理仓库,用于代理远程仓库
  • ​group:仓库组,通常包含了多个代理仓库和宿主仓库
  • hosted:宿主仓库,内部项目、付费jar等 ​
  • releases:发布内部release版本的仓库
  • snapshots:发布内部snapshots版本的仓库
  • third 自建的第三方jar仓库

配置代理

http://maven.aliyun.com/nexus/content/groups/public/

在这里插入图片描述

本地Maven配置

  1. 修改本地maven目录下的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">
  
  <pluginGroups>
  </pluginGroups>

  <servers>
    <server>
      <id>cax-releases</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
    <server>
      <id>cax-snapshots</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>

  <proxies>
  </proxies>

  <mirrors>
  </mirrors>
  
  <profiles>
	<profile>
      <id>cax</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <!-- 私有库地址-->
      <repositories>
        <repository>
          <id>cax</id>
          <url>http://192.168.48.128:8081/repository/maven-public/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
      <!--插件库地址-->
      <pluginRepositories>
        <pluginRepository>
          <id>cax</id>
          <url>http://192.168.48.128:8081/repository/maven-public/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>  
  </profiles>
  <activeProfiles>
    <activeProfile>cax</activeProfile>
  </activeProfiles>
  
</settings>

修改IDEA的maven配置指向自定义的setting.xml

在这里插入图片描述

测试

当我们往pom文件中加入本地maven仓库没有的依赖,查看是否使用了nexus代理
如果使用了,则会在nexus的控制台查看到以下界面(取决于你添加的依赖)
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值