name: 97年的顽石
avatar: /images/husky.png
home:
authorDesc: 一条咸鱼罢了
categories: 科技
tags:
mirror和repository的区别 概念在文章 → Maven:mirror和repository 区别 - bcombetter - 博客园(https://www.cnblogs.com/xingzc/p/9678984.html)
(使用时把aliyun配置在nexus里,pom.xml和setting.xml只留私服)
(使用时把aliyun配置在nexus里,pom.xml和setting.xml只留私服)
效果就是Maven的所有请求必须经过镜像站点(Nexus);当Nexus出现问题后,那么Maven将强制不可用。
<mirror>
<id>mirror-redirect2nexusid>
<mirrorOf>*mirrorOf>
<name>Nexus oscname>
<url>http://192.168.213.135:8081/repository/maven-public/url>
mirror>
<server>
<id>nexus-releasesid>
<username>adminusername>
<password>admin123password>
server>
<server>
<id>nexus-snapshotsid>
<username>adminusername>
<password>admin123password>
server>
Release 版本与 Snapshot 定义如下:
Release: 1.0.0/1.0.0-RELEASE
Snapshot: 1.0.0-SNAPSHOT
在(IDEA)pom.xml 中添加如下代码:
<distributionManagement>
<repository>
<id>nexus-releasesid>
<name>Nexus Release Repositoryname>
<url>http://192.168.213.135:8081/repository/maven-releases/url>
repository>
<snapshotRepository>
<id>nexus-snapshotsid>
<name>Nexus Snapshot Repositoryname>
<url>http://192.168.213.135:8081/repository/maven-snapshots/url>
snapshotRepository>
distributionManagement>
注意事项:
mvn deploy
Nexus 3.0 不支持页面上传,可使用 maven 命令:
# 如第三方JAR包:aliyun-sdk-oss-2.2.3.jar
mvn 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
注意事项:
(使用时把aliyun配置在nexus里,pom.xml和setting.xml只留私服)
<repositories>
<repository>
<id>nexusid>
<name>Nexus Repositoryname>
<url>http://192.168.213.135:8081/repository/maven-public/url>
<snapshots>
<enabled>trueenabled>
snapshots>
<releases>
<enabled>trueenabled>
releases>
repository>
repositories>
<pluginRepositories>
<pluginRepository>
<id>nexusid>
<name>Nexus Plugin Repositoryname>
<url>http://192.168.213.135:8081/repository/maven-public/url>
<snapshots>
<enabled>trueenabled>
snapshots>
<releases>
<enabled>trueenabled>
releases>
pluginRepository>
pluginRepositories>
# Nexus添加阿里云仓库(http://192.168.213.135:8081 登陆并设置**):**
(使用时把aliyun配置在nexus里,pom.xml和setting.xml只留私服)
把一下都配上,并设置maven-public 调整到 maven-release/public/centrol 之前.(范例在代码最下方)
setting.xml
<mirror>
<id>alimavenid>
<name>aliyun mavenname>
<url>http://maven.aliyun.com/nexus/content/groups/public/url>
<mirrorOf>centralmirrorOf>
mirror>
<mirror>
<id>centralid>
<name>Maven Repository Switchboardname>
<url>http://repo1.maven.org/maven2/url>
<mirrorOf>centralmirrorOf>
mirror>
<mirror>
<id>repo2id>
<mirrorOf>centralmirrorOf>
<name>Human Readable Name for this Mirror.name>
<url>http://repo2.maven.org/maven2/url>
mirror>
<mirror>
<id>ibiblioid>
<mirrorOf>centralmirrorOf>
<name>Human Readable Name for this Mirror.name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/url>
mirror>
<mirror>
<id>jboss-public-repository-groupid>
<mirrorOf>centralmirrorOf>
<name>JBoss Public Repository Groupname>
<url>http://repository.jboss.org/nexus/content/groups/publicurl>
mirror>
<mirror>
<id>maven.net.cnid>
<name>oneof the central mirrors in chinaname>
<url>http://maven.net.cn/content/groups/public/url>
<mirrorOf>centralmirrorOf>
mirror>
pom.xml
<repositories>
<repository>
<id>aliyun-reposid>
<name>Aliyun Repositoryname>
<url>http://maven.aliyun.com/nexus/content/groups/publicurl>
<releases>
<enabled>trueenabled>
releases>
<snapshots>
<enabled>falseenabled>
snapshots>
repository>
repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun-reposid>
<name>Aliyun Repositoryname>
<url>http://maven.aliyun.com/nexus/content/groups/publicurl>
<releases>
<enabled>trueenabled>
releases>
<snapshots>
<enabled>falseenabled>
snapshots>
pluginRepository>
pluginRepositories>
范例: 如下图,点击 Repositories → Create repository → maven2 proxy
取名: aliyun-repository
URL:http://maven.aliyun.com/nexus/content/groups/public/
,其他默认值即可。