maven配置使用nexus仓库

一、前言

    nexus一般用来作为包仓库,用来存储公共依赖包,有其它包需要使用依赖包的都会到nexus仓库调用

二、配置

在maven配置文件中配置nexus仓库

vi /opt/maven/apache-maven-3.9.6/conf/settings.xml 

<proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>
  <servers>          #增加该段配置
    <server>
      <id>yl_nexus</id>   #代码中的调用配置需要与改id相同,即pom.xml中的配置
      <username>deploy</username>    #nexus仓库的用户名
      <password>12345678</password>  #nexus仓库的密码
    </server> 
  </servers>

  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
   |-->

    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     |
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     |
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    -->

在代码配置文件中配置nexus仓库的调用

vi pom.xml

    <distributionManagement>
        <repository>
            <id>yl_nexus</id>     #需要与maven配置文件中的id一致
            <name>yl Repository</name>
            <url>http://10.1.60.14:30001/repository/yl-releases/</url>  #配置nexus调用接口
        </repository>
        <snapshotRepository>
            <id>yl_nexus</id>
            <name>yl Snapshot Repository</name>
            <url>http://10.1.60.14:30001/repository/yl-snapshots/</url>
        </snapshotRepository>

    </distributionManagement>
</project>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值