正确使用Maven私有库下载依赖以及修改maven的VM options for importer参数,解决一直卡在resolving

作为一个小白,刚接触maven时候,有时候新建了一个maven项目,一打开就要一直卡在resolving dependencies。

上网查了相关博客,知道了因为是在国外的中央仓库下载依赖的,所以速度很慢,可以使用国内的镜像来解决此问题。也从网上查了国内镜像的配置代码。

但是仅仅在maven的配置文件setting.xml添加国内的几个镜像根本没有作用!!!因为还有重要的一步还没做

即使在maven的配置文件中加入国内的几个镜像,发现一直卡在resolving dependencies那里,而已也是辛辛苦苦等了好久好久才发现,原来下载地址还一直是国外的中央仓库:Downloading: http://repo.maven.apache.org/maven2/。

正确使用maven私有库下载依赖之后,发现用了大半天的时间,用国内镜像一下子就下载好了。这个问题困惑了我一天时间啊啊啊啊啊

正确使用maven私有库下载依赖的做法:

  1. 在maven的配置文件setting.xml中加入国内的镜像
  2. 在项目的pom.xml加入配置
  3. 注意:两个配置文件中的镜像id应该一致

setting.xml中加入的国内镜像代码如下:

    <mirror>
		<id>alimaven</id>
		<name>aliyun maven</name>
		<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
		<mirrorOf>central</mirrorOf>
	</mirror>

	<mirror>
		<id>uk</id>
		<mirrorOf>central</mirrorOf>
		<name>Human Readable Name for this Mirror.</name>
		<url>http://uk.maven.org/maven2/</url>
	</mirror>

	<mirror>
		<id>CN</id>
		<name>OSChina Central</name>
		<url>http://maven.oschina.net/content/groups/public/</url>
		<mirrorOf>central</mirrorOf>
	</mirror>

	<mirror>
		<id>nexus</id>
		<name>internal nexus repository</name>
		<url>http://repo.maven.apache.org/maven2</url>
		<mirrorOf>central</mirrorOf>
	</mirror>

pom.xml中加入的插件代码:

    <repositories>
        <repository>
            <id>alimaven</id>
            <url>https://maven.aliyun.com/repository/public</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>alimaven</id>
            <url>https://maven.aliyun.com/repository/public</url>
        </pluginRepository>
    </pluginRepositories>

附上修改maven的相关参数VM options for importer加快resolving dependencies

File—>Settings—>Build,Execution,Deployment—>Build Tools—>maven—>Importing

VM options for importer的默认768m修改为**-Xms1024m -Xmx2048m**

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值