解决Maven下载依赖慢的问题
解决Maven下载依赖慢的问题,使用Maven构建项目时,项目中有的依赖包可能下载的非常慢,我们可以通过配置镜像来解决这个问题。
在Maven的配置文件(%MAVEN%/conf/setting.xml)中的 标签中加入
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
还有以下常用库:
http://repo1.maven.org/maven2/
http://mirrors.ibiblio.org/pub/mirrors/maven2/org/acegisecurity/
http://repository.jboss.com/maven2/
http://repository.sonatype.org/content/groups/public/
Failed to copy file for artifact
While building project:
Group-Id: xxx
Artifact-Id: xxxx
Version: x.x.x
From file: E:\workspace\xxxx\pom.xml
Reason: Failed to copy file for artifact[xxx:xxxx:jar:x.x.x:compile]
错误原因是:要下载的这个xxx.xxxx.x.x.x.jar这个包,在本地已经有一个xxxx的工程,先将这工程关掉,然后再去mvn war:inplace一下就不会有 问题了。
修改local repository
修改settings.xml文件:
在文件中找到
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
在其后添加内容:
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<localRepository>${user.home}/repository/maven</localRepository>
其中:${user.home}/repository/maven是你maven本地仓库的路径。
保存退出。