下载地址
版本太高jdk8不兼容
Index of /dist/maven/maven-3/3.6.3/binaries (apache.org)
配置文件
Maven之配置文件 - 简书 (jianshu.com)
Maven 构建配置文件 | 菜鸟教程 (runoob.com)
基本配置
<?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>D:\Maven\Maven仓库</localRepository>
<mirrors>
<mirror>
<!--镜像唯一标识-->
<id>aliyun</id>
<!--对应非本地仓库id,对应的仓库下载依赖路径会被替换为镜像url,
为了满足一些较为复杂的需求,Maven 还支持一些更为高级的配置。
<mirrorOf>*</mirrorOf>:匹配所有远程仓库。
<mirrorOf>external:*</mirrorOf>:匹配所有远程仓库,使用 localhost 和 file:// 协议的除外。即,匹配所有不在本机上的远程仓库。
<mirrorOf>repo1,repo2</mirrorOf>:匹配仓库 repo1 和 repo2,使用逗号分隔多个远程仓库。
<mirrorOf>*,!repo1</miiroOf>:匹配所有远程仓库,repo1 除外,使用感叹号将仓库从匹配中排除。-->
<mirrorOf>central,aliyun</mirrorOf>
<name>阿里云公共仓库</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
<!--根据环境参数来调整构建配置的列表。settings.xml中的profile元素是pom.xml中profile元素的裁剪版本。
它包含了id,activation, repositories, pluginRepositories和 properties元素。
这里的profile元素只包含这五个子元素是因为这里只关心构建系统这个整体(这正是settings.xml文件的角色定位),而非单独的项目对象模型设置。
如果一个settings中的profile被激活,它的值会覆盖任何其它定义在POM中或者profile.xml中的带有相同id的profile。 -->
<profiles>
<profile>
<!-- 启用该配置所需环境名 -->
<id>my</id>
<repositories>
<!-- 新加远程仓库 -->
<repository>
<!-- 用于识别远程仓库唯一id -->
<id>aliyun</id>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</repository>
</repositories>
</profile>
</profiles>
<!--手动激活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>my</activeProfile>
</activeProfiles>
</settings>
pom.xml
<depedencymanagement></depedencymanagement>
中的依赖一定要带有版本号,否则子项目中什么依赖都导不进去。
常见问题
IDEA远程仓库索引下载失败
1.maven vm 中 添加
-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true
- 注意idea maven 中jdk和jre版本,默认的可能和实际使用的不同
- 阿里云的下载一直失败,但默认远程中央仓库能下载,各种方法都试了,没找到具体原因
只在这篇18年博客里找到一句
最近阿里云私服改版,暂时没提供nexus-maven-repository-index.properties文件