一、前言
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>