用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>
-->
一顿操作之后,终于同步成功咯,欧耶(o)/。