idea自定义maven配置

为什么要自定义,如果默认本地仓库放c盘,系统盘很快就会满了,系统盘满了,系统就越来越慢了,另外连默认的maven仓库可能会比较慢,连接国内的会比较快一点。maven最好用自己下载的,不要用系统自带,自带的默认会从国外站点下载依赖。会出现无法下载完整依赖jar的问题。

file-->Settings-->Build-->Maven

 目前下载挺快,打包都正常的settings.xml分享给大家

<?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
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
   -->
   <localRepository>E:/mvnrep/.m2/repository</localRepository>
  <mirrors>
       <mirror>
		  <id>repo1</id>
		  <mirrorOf>central</mirrorOf>
		  <name>Mirror from Maven Repo1</name>
		  <url>https://repo1.maven.org/maven2</url>
       </mirror>

	   <mirror>
		  <id>repo2</id>
		  <name>Mirror from Maven Repo2</name>
		  <url>http://repo2.maven.org/maven2/</url>
		  <mirrorOf>central</mirrorOf>
       </mirror>
	   <mirror>  
		 <id>aliyunmaven</id>
		 <mirrorOf>central</mirrorOf>
		 <name>阿里云公共仓库</name>
		 <url>https://maven.aliyun.com/repository/public</url>
	  </mirror>
	  <mirror>
	    <!--该镜像的id-->
	    <id>nexus-aliyun</id>
	    <!--该镜像用来取代的远程仓库,central是中央仓库的id-->
	    <mirrorOf>central</mirrorOf>
	    <name>Nexus aliyun</name>
	    <!--该镜像的仓库地址,这里是用的阿里的仓库-->
	    <url>http://maven.aliyun.com/nexus/content/repository/central</url>
	 </mirror>
     <!--
	 <mirror>  
       <id>alimaven</id>  
       <name>aliyun maven</name>  
       <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
       <mirrorOf>central</mirrorOf>          
     </mirror> 
     -->
  

	
  </mirrors>
 
</settings>

多次实验发现aliyun的仓库经常会下载不了最新的jar,如果是这样settings.xml里面重新排一下位置,比如把repo1,或者repo2放到第一个位置去,上面配置已经改动过顺序,如果第一个能联通,maven只会从第一个mvn仓库进行依赖jar的下载。下载不了不会跳转到第二个仓库,建议maven开发者能改善一下这个情况。

猜你喜欢

转载自blog.csdn.net/figo0423/article/details/126887510