标签:成功 接口 配置 services ssi port mave 策略 The
Nexus 是一个强大的 Maven 仓库管理器,极大地简化了内部仓库的维护和外部仓库的访问。2016 年 4 月 6 日 Nexus 3.0 版本发布,相较 2.x 版本有了很大的改变
我们使用 Docker 来安装和运行 Nexus,docker-compose.yml 配置如下:
version: ‘3.1‘services: nexus: restart: always image: sonatype/nexus3 container_name: nexus ports: - 80:8081 volumes: - data:/nexus-data volumes: data:注意: 新版本密码在
cat /var/lib/docker/volumes/nexus_data/_data/admin.password

通常包含了多个代理仓库和宿主仓库,在项目中只要引入仓库组就可以下载到代理仓库和宿主仓库中的包
在 Maven settings.xml 中添加 Nexus 认证信息 (servers 节点下)
<server> <id>nexus-releases</id> <username>admin</username> <password>admin123</password></server><server><id>nexus-snapshots</id><username>admin</username><password>admin123</password></server>
Release 版本与 Snapshot 定义
Release: 1.0.0/1.0.0-RELEASESnapshot: 1.0.0-SNAPSHOTpom.xml 中设置的版本号添加 SNAPSHOT 标识的都会发布为 SNAPSHOT 版本,没有 SNAPSHOT 标识的都会发布为 RELEASE 版本。SNAPSHOT 版本会自动加一个时间作为标识,如:1.0.0-SNAPSHOT 发布后为变成 1.0.0-SNAPSHOT-20180522.123456-1.jar在 pom.xml 中添加如下代码
<distributionManagement> <repository> <id>nexus-releases</id> <name>Nexus Release Repository</name> <url>http://127.0.0.1:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>nexus-snapshots</id> <name>Nexus Snapshot Repository</name> <url>http://127.0.0.1:8081/repository/maven-snapshots/</url> </snapshotRepository></distributionManagement>注意事项
settings.xml 中 Servers 配置的 ID 名称保持一致SNAPSHOT 标识的,会发布到 Nexus Snapshots Repository, 否则发布到 Nexus Release Repository,并根据 ID 去匹配授权账号mvn deploy<repositories> <repository> <id>nexus</id> <name>Nexus Repository</name> <url>http://127.0.0.1:8081/repository/maven-public/</url> <snapshots> <enabled>true</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </repository></repositories><pluginRepositories> <pluginRepository> <id>nexus</id> <name>Nexus Plugin Repository</name> <url>http://127.0.0.1:8081/repository/maven-public/</url> <snapshots> <enabled>true</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </pluginRepository></pluginRepositories>Nexus 3.1.x 开始支持页面上传第三方依赖功能,以下为手动上传命令
# 如第三方JAR包:aliyun-sdk-oss-2.2.3.jarmvn deploy:deploy-file-DgroupId=com.aliyun.oss-DartifactId=aliyun-sdk-oss-Dversion=2.2.3-Dpackaging=jar-Dfile=D:\aliyun-sdk-oss-2.2.3.jar-Durl=http://127.0.0.1:8081/repository/maven-3rd/-DrepositoryId=nexus-releases注意事项
-DrepositoryId=nexus-releases 对应的是 settings.xml 中 Servers 配置的 ID 名称。(授权)标签:成功 接口 配置 services ssi port mave 策略 The
原文地址:https://www.cnblogs.com/xianquan/p/12369221.html