当前示范版本nexus-3.19.1-01
1.私服下载地址:https://help.sonatype.com/repomanager2/download/download-archives—repository-manager-oss(如图)
2. 下载后解压,用cmd进入nexus-3.19.1-01\bin目录;安装windows服务命令nexus.exe install
3. nexus-3.19.1-01\etc\nexus-default.properties默认配置,admin初始密码位置sonatype-work\nexus3\admin.password
4. 修改远程代理的地址eg:http://maven.aliyun.com/nexus/content/groups/public/
5. springboot-gradle配置依赖包的库(当私服没有该依赖包时,使用远程拉依赖包并缓存一份在私服上)
//私服地址,
repositories {
maven {
def releasesUrl = "http://192.168.124.4:8081/repository/maven-releases/"
def snapshotsUrl = "http://192.168.124.4:8081/repository/maven-snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsUrl : releasesUrl
credentials {
username = 'admin' //私服用户名
password = 'nexus672873953' //私服密码
}
}
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
}
- maven配置打开setting.xml。
①mirrors标签配置依赖maven仓库
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
| 第一个是私服的,第二个是阿里云的仓库
-->
<mirror>
<id>nexus</id>
<mirrorOf>central</mirrorOf>
<name>nexus maven</name>
<url>http://192.168.124.4:8081/repository/maven-public/</url>
</mirror>
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<!-- <name>mvnrepository</name>
<url>https://mvnrepository.com/nexus/content/groups/public/</url>
-->
</mirror>
</mirrors>
②上传自制包到私服
<servers>
<!-- 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.
| 上传自制包到私服,即自制的jar包
-->
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>password</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>password</password>
</server>
<!-- Another sample, using keys to authenticate.
<server>
<id>siteServer</id>
<privateKey>/path/to/private/key</privateKey>
<passphrase>optional; leave empty if not used.</passphrase>
</server>
-->
</servers>
③…