Intellij 2021.3:更新到 intellij 2021.3 后,Maven 无法解析依赖项

Raj*_*jat 7 intellij-idea maven-3 maven

在 2021.2 中一切正常,但当在 2021.3 打开同一个项目时,出现以下错误

http://0.0.0.0/ during a previous attempt. This failure was cached in the local repository and resolution will not be reattempted until the update interval of maven-default-http-blocker has elapsed or updates are forced. Original error: Could not transfer metadata com.domain.sub-domain.project:private-commons:1.0.0-SNAPSHOT/maven-metadata.xml from/to maven-default-http-blocker (http://0.0.0.0/): transfer failed for http://0.0.0.0/com/domain/sub-domain/project/private-repo/1.0.0-SNAPSHOT/maven-metadata.xml
Cannot resolve junit:junit:4.12
Cannot resolve org.apache.camel:camel-test:2.23.0
Cannot resolve com.amazonaws:aws-java-sdk-glacier:1.11.415
Run Code Online (Sandbox Code Playgroud)

屏幕拍摄

And*_*rey 18

2021.3 IDE 版本已将捆绑的 Maven 版本更新为3.8.1. 在此版本http中,Maven默认阻止对存储库的访问。在此之前,Maven 本身已经不再使用 http 存储库

因此,现在需要显式配置 Maven 以允许http在项目中使用存储库。例如,settings.xml向您的 http 存储库添加一个允许 HTTP 的镜像:

<mirrors>
    <mirror>
        <id>my-repo-mirror</id>
        <name>My Repo HTTP Mirror</name>
        <url>http://url-to.my/repo</url>
        <mirrorOf>my-repo</mirrorOf>
    </mirror>
</mirrors>
Run Code Online (Sandbox Code Playgroud)

您还可以查看/sf/answers/4690199671/上的相关讨论,了解配置方法。

另一个选项是在 IDE 中指定较旧的 Maven 版本:设置(macOS 上的首选项)| 构建、执行、部署 | 构建工具| Maven | Maven 主路径

  • 对我来说,只需更改设置(macOS 上的首选项)| 构建、执行、部署 | 构建工具| Maven | **Maven 主路径** 到 **用户 Maven 包装器** (3认同)