安装maven并配置环境
把maven改到国内的环境并设置仓库
改过或者设置过的请跳过
修改远程中央仓库
我们用Maven的时候,因为Maven自带的远程中央仓库在国外,所以经常会很慢。我们可以把远程中央仓库改为国内阿里的远程仓库。 找到你的Maven安装位置,打开conf目录下的setting.xml 将原文件红色方框处改为:
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
复制代码
OR 再pom.xml里面设置 实测,速度起飞。如果是Spring 项目,可使用阿里代理仓库,
在<repositories></repositories>标签中加入对应的仓库使用地址。以使用spring代理仓为例:
复制代码
<repository>
<id>spring</id>
<url>https://maven.aliyun.com/repository/spring</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
复制代码
修改本地仓库位置(如果不想修改本地仓库位置则这一步骤可省略)
Maven会将下载的类库(jar包)放置到本地的一个目录下(一般默认情况下Maven在本机的仓库位于C:\Users\你的电脑用户账号.m2\repository) 创建你要作为本地仓库的文件夹,我所创建文件夹的路径为C:\Program Files\Apache Software Foundation\maven-repository 在setting.xml里找到下图所示
在红方框代码下加上一行代码:
<localRepository>E:\maven\maven-repo</localRepository>
这个是自己电脑仓库的地址
IDEA设置maven环境
把路径的改到maven的主目录
改到其他盘,比较好管理
maven里面需要的jar包可以重复使用