IDEA与3.8.1版本Maven踩坑记录

搬砖过程中发现有个依赖不能满足业务需求,需要升级到一个指定的快照版本。大家都知道,在pom.xml文件中可以修改依赖的版本号。

        <dependency>
            <groupId>com.xxx</groupId>
            <artifactId>commons-xxx</artifactId>
            <version>2.0.0-SNAPSHOT</version>
        </dependency>

用IDEA重新加载maven项目,结果同步失败,询问后得知这个版本的jar包存放在另一个远程仓库中,需要要换个仓库地址。嗯这也不难,改一下maven的设置文件setting.xml就行。

  <mirrors>
    <mirror>
        <id>repo1</id>
        <mirrorOf>central</mirrorOf>
        <name>central repository.</name>
        <url>http://xxx.xxx/nexus/content/groups/public</url>
    </mirror>
 </mirrors>

重新加载maven项目,啊又翻车了,IDEA提示:

Blocked mirror for repositories: [public (http://yyy.yyy/nexus/content/groups/public, default, releases+snapshots)]

Since Maven 3.8.1 http repositories are blocked.

Possible solutions:
- Check that Maven settings.xml does not contain http repositories
- Check that Maven pom files not contain http repository http://yyy.yyy/nexus/content/groups/public
- Add a mirror(s) for http://yyy.yyy/nexus/content/groups/public that allows http url in the Maven settings.xml
- Downgrade Maven to version before 3.8.1 in settings

第一眼看过去,仓库地址怎么没变?好吧,检查一下setting文件试试

mvn help:effective-settings

setting文件没有异常,重新加载了n次仓库地址还是没变。当我开始怀疑人生时,想起了一件事,maven一天只会更新一次snapshot依赖,可能是这个原因。

在IDEA的设置中搜索maven,勾选始终更新快照。
在这里插入图片描述
虽然还是同步失败,但这回的仓库地址总算对了,有进步了。

又仔细看了一眼IDEA提示的信息,Maven从3.8.1版本开始就禁用了http仓库。
以前使用的低版本maven,并没有这种限制。起因是不久前曾升级过IDEA,导致内置的maven也连带着升级了。

问题是私服地址没有https的,又不想更换Maven的版本,这可怎么办?这时就轮到度娘登场了
搜索一下就马上找到了答案:IDEA升级到2021.3之后,Maven私有仓库不能用的解决

在idea的安装目录plugins\maven\lib\maven3\conf下,找到setting.xml文件,注释掉镜像maven-default-http-blocker。

	 <!--
    <mirror>
      <id>maven-default-http-blocker</id>
      <mirrorOf>external:http:*</mirrorOf>
      <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
      <url>http://0.0.0.0/</url>
      <blocked>true</blocked>
    </mirror>
	-->

一顿操作之后,终于同步成功了,可喜可贺。

  • 22
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值