很基础的问题了,搞错了仓库地址一直拉取失败,折腾了很久,记录下:
setting.xml的结构,配置一个中央仓库镜像一般也够用了,多个私服仓库配置respository列表即可,别忘了激活
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- 本地仓库的路径 -->
<localRepository>E:\repository</localRepository>
<servers>
<server>
<!--这是server的id(注意不是用户登陆的id),该id与distributionManagement中repository元素的id相匹配。 -->
<id>ig_releases</id>
<username>name</username>
<password>pwd</password>
</server>
<server>
<id>ig_snapshots</id>
<username>name</username>
<password>pwd</password>
</server>
<server>
<id>public</id>
<username>name</username>
<password>pwd</password>
</server>
</servers>
<mirrors>
<!--给定仓库的下载镜像。 -->
<mirror>
<!--该镜像的唯一标识符,用来区分不同的mirror元素 -->
<id>nexus-aliyun</id>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<!--被镜像的服务器的id。例如,如果我们要设置了一个Maven中央仓库(http://repo1.maven.org/maven2)的镜像,-->
<!--就需要将该元素设置成central。这必须和中央仓库的id central完全一致。 -->
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>dev</id>
<!--远程仓库列表,它是Maven用来填充构建系统本地仓库所使用的一组远程项目。 -->
<repositories>
<repository>
<id>ig_releases</id>
<url>http://192.168.5.176:8080/nexus/content/repositories/releases/</url>
<releases>
<!--enabled为true或者false表示该仓库是否为下载某种类型构件(发布版,快照版)开启。 -->
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>ig_snapshots</id>
<url>http://192.168.5.176:8080/nexus/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<url>http://nexus.xxx.io/repository/snapshots/</url>
</repository>
<repository>
<id>release</id>
<url>http://nexus.xxx.io/repository/releases/</url>
</repository>
<repository>
<id>public</id>
<url>http://nexus.xxx.io/repository/public/</url>
</repository>
</repositories>
</profile>
</profiles>
<!--如果一个settings中的profile被激活,它的值会覆盖任何其它定义在POM中或者profile.xml中的带有相同id的profile。 -->
<!--手动激活profiles的列表,按照profile被应用的顺序定义activeProfile。 该元素包含了一组activeProfile元素,每个activeProfile都含有一个profile id。-->
<!--任何在activeProfile中定义的profile id,不论环境设置如何,其对应的 profile都会被激活。-->
<!--如果没有匹配的profile,则什么都不会发生。例如,env-test是一个activeProfile,则在pom.xml(或者profile.xml)中对应id的profile会被激活。-->
<!--如果运行过程中找不到这样一个profile,Maven则会像往常一样运行。 -->
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
</settings>
本文详细介绍了Maven的setting.xml文件配置,包括本地仓库路径、中央仓库镜像、私服仓库、远程仓库列表及激活配置。解析了各元素的作用,如server、mirror、repository等,帮助理解Maven依赖管理。
2082

被折叠的 条评论
为什么被折叠?



