【整理】idea配置maven

本文详细介绍了如何配置Maven的setting.xml文件,包括设置阿里镜像加速下载,指定本地仓库位置,以及为新项目提供快速加载的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

1.maven的setting.xml文件的配置

1.设置阿里镜像

2.设置本地仓库

2.为当前项目配置maven

3.为未来创建的新项目配置maven


1.maven的setting.xml文件的配置

maven的setting.xml文件放在安装的maven的conf目录下。

可以在idea中找到使用的setting.xml。

设置两个东西,一个是阿里的镜像,另一个是本地仓库。

1.设置阿里镜像

打开文件直接搜索mirror可以定位,然后添加以下内容:

      <mirror>
          <id>aliyunmaven</id>
          <mirrorOf>*</mirrorOf>
          <name>阿里云公共仓库</name>
          <url>https://maven.aliyun.com/repository/public</url>
      </mirror>

        哎呀,最近用阿里云的镜像感觉老是找不到依赖,干脆多加几个,总有一个能用。

    <mirror>
	  <id>central</id>
	  <mirrorOf>central</mirrorOf>
	  <name>Central Repository</name>
	  <url>https://repo.maven.apache.org/maven2</url>
	</mirror>
	<mirror>
	  <id>tencent</id>
	  <mirrorOf>central</mirrorOf>
	  <name>Tencent Cloud Maven</name>
	  <url>https://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url>
	</mirror>

	<mirror>
	  <id>huaweicloud</id>
	  <mirrorOf>central</mirrorOf>
	  <name>Huawei Cloud Maven</name>
	  <url>https://repo.huaweicloud.com/repository/maven/</url>
	</mirror>
   <mirror>  
    <id>alimaven</id>  
    <name>aliyun maven</name>  
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    <mirrorOf>central</mirrorOf>          
    </mirror>
	<mirror>
	  <id>tuna</id>
	  <mirrorOf>central</mirrorOf>
	  <name>TUNA Maven</name>
	  <url>https://mirrors.tuna.tsinghua.edu.cn/maven/</url>
	</mirror>

	<mirror>
	  <id>ustc</id>
	  <mirrorOf>central</mirrorOf>
	  <name>USTC Maven</name>
	  <url>https://mirrors.ustc.edu.cn/maven/</url>
	</mirror>
2.设置本地仓库

这里搜索localRepository,然后添加自己想设置的本地仓库地址(就是一个文件夹),尽量设置在c盘之外,后面的依赖越来越多c盘可能会爆满。

3. 配置阿里spring代理仓库

        在<profiles>标签下加入以下配置。

<!--      阿里spring代理仓库配置-->
      <profile>
          <id>aliyun</id>
          <repositories>
              <repository>
                  <id>spring</id>
                  <url>https://maven.aliyun.com/repository/spring</url><!-- spring仓库-->
                  <releases>
                      <enabled>true</enabled>
                  </releases>
                  <snapshots>
                      <enabled>true</enabled>
                  </snapshots>
              </repository>
              <repository>
                  <id>spring-boot-maven-plugin</id>
                  <url>https://maven.aliyun.com/repository/spring-plugin</url><!-- spring-boot插件仓-->
                  <releases>
                      <enabled>true</enabled>
                  </releases>
                  <snapshots>
                      <enabled>true</enabled>
                  </snapshots>
              </repository>
              <repository>
                  <id>central</id>
                  <url>https://maven.aliyun.com/repository/central</url><!-- 中央仓-->
                  <releases>
                      <enabled>true</enabled>
                  </releases>
                  <snapshots>
                      <enabled>true</enabled>
                  </snapshots>
              </repository>
          </repositories>
      </profile>

2.为当前项目配置maven

在setting中搜索maven

3.为未来创建的新项目配置maven

只设置上述内容会发现,每次新创建的项目加载还是很慢【坑!】,所以还是需要配置下面的内容。

在File-》New Projects Setup-》Settings for New Projects下设置maven

参考链接:

idea Maven阿里云仓库和阿里spring代理仓库配置_maven代理阿里-CSDN博客

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

睆小白

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值