当前位置:   article > 正文

maven配置使用nexus仓库_maven setting.xml配置本地nexus仓库

maven setting.xml配置本地nexus仓库

一、前言

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

二、配置

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

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

  1. <proxies>
  2. <!-- proxy
  3. | Specification for one proxy, to be used in connecting to the network.
  4. |
  5. <proxy>
  6. <id>optional</id>
  7. <active>true</active>
  8. <protocol>http</protocol>
  9. <username>proxyuser</username>
  10. <password>proxypass</password>
  11. <host>proxy.host.net</host>
  12. <port>80</port>
  13. <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
  14. </proxy>
  15. -->
  16. </proxies>
  17. <servers> #增加该段配置
  18. <server>
  19. <id>yl_nexus</id> #代码中的调用配置需要与改id相同,即pom.xml中的配置
  20. <username>deploy</username> #nexus仓库的用户名
  21. <password>12345678</password> #nexus仓库的密码
  22. </server>
  23. </servers>
  24. <!-- servers
  25. | This is a list of authentication profiles, keyed by the server-id used within the system.
  26. | Authentication profiles can be used whenever maven must make a connection to a remote server.
  27. |-->
  28. <!-- server
  29. | Specifies the authentication information to use when connecting to a particular server, identified by
  30. | a unique name within the system (referred to by the 'id' attribute below).
  31. |
  32. | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
  33. | used together.
  34. |
  35. <server>
  36. <id>deploymentRepo</id>
  37. <username>repouser</username>
  38. <password>repopwd</password>
  39. </server>
  40. -->

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

vi pom.xml

  1. <distributionManagement>
  2. <repository>
  3. <id>yl_nexus</id> #需要与maven配置文件中的id一致
  4. <name>yl Repository</name>
  5. <url>http://10.1.60.14:30001/repository/yl-releases/</url> #配置nexus调用接口
  6. </repository>
  7. <snapshotRepository>
  8. <id>yl_nexus</id>
  9. <name>yl Snapshot Repository</name>
  10. <url>http://10.1.60.14:30001/repository/yl-snapshots/</url>
  11. </snapshotRepository>
  12. </distributionManagement>
  13. </project>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/爱喝兽奶帝天荒/article/detail/809238
推荐阅读
相关标签
  

闽ICP备14008679号