Maven 和 Spring Boot - 不可解析的父 pom - repo.spring.io(未知主机)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32125025/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 00:44:42  来源:igfitidea点击:

Maven and Spring Boot - non resolvable parent pom - repo.spring.io (Unknown host)

springmavenspring-bootpom.xmlparent-pom

提问by Kingamere

I am trying to build my project but I get this:

我正在尝试构建我的项目,但我得到了这个:

Non-resolvable parent POM: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.3.0.M3 from/to spring-snapshots (http://repo.spring.io/snapshot): repo.spring.io and 'parent.relativePath' points at no local POM @ line 16, column 10: Unknown host repo.spring.io -> [Help 2]

不可解析的父 POM:无法传输工件 org.springframework.boot:spring-boot-starter-parent:pom:1.3.0.M3 from/to spring-snapshots ( http://repo.spring.io/snapshot) :repo.spring.io 和 'parent.relativePath' 指向没有本地 POM @ 第 16 行,第 10 列:未知主机 repo.spring.io -> [帮助 2]

Here is how I specify the parent of my pom.xml:

这是我如何指定 pom.xml 的父级:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.0.M3</version>
        <relativePath></relativePath>
    </parent>

The is empty so that it forces maven to look for the parent in the remote repository. However, it says that repo.spring.io is an unknown host.

为空,以便强制 maven 在远程存储库中查找父级。但是,它说repo.spring.io 是一个未知主机

Here is how I define the repositories in my pom.xml:

这是我在 pom.xml 中定义存储库的方式:

<repositories>
        <repository>
            <id>spring-snapshots</id>
            <url>http://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <url>http://repo.spring.io/milestone</url>
        </repository>
    </repositories>

<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <url>http://repo.spring.io/snapshot</url>
    </pluginRepository>
    <pluginRepository>
        <id>spring-milestones</id>
        <url>http://repo.spring.io/milestone</url>
    </pluginRepository>
</pluginRepositories>

Any ideas?

有任何想法吗?

回答by dunni

Obviously it's a problem with your internet connection. Check, if you can reach http://repo.spring.iowith your browser. If yes, check if you need to configure a proxy server. If no, you should contact your internet provider.

显然这是您的互联网连接问题。检查是否可以使用浏览器访问http://repo.spring.io。如果是,请检查是否需要配置代理服务器。如果没有,您应该联系您的互联网提供商。

Here is the documentation, how you configure a proxy server for Maven: https://maven.apache.org/guides/mini/guide-proxies.html

这是文档,您如何为 Maven 配置代理服务器:https: //maven.apache.org/guides/mini/guide-proxies.html

回答by lgpasquale

For anyone stumbling upon this question, I'll post the solution to a similar problem (same error message except for the uknown hostpart).

对于遇到此问题的任何人,我将发布类似问题的解决方案(除uknown host部分外,错误消息相同)。

Since January 15, 2020 maven central no longer supports HTTP, in favour of HTTPS. Consequently, spring repositories switched to HTTPS as well

自 2020 年 1 月 15 日起,maven central不再支持 HTTP,转而支持 HTTPS。因此,spring 存储库也切换到了 HTTPS

The solution is therefore to change the urls from http://repo.spring.io/milestoneto https://repo.spring.io/milestone.

因此,解决方案是将 urls 从 更改http://repo.spring.io/milestonehttps://repo.spring.io/milestone

回答by arif abbas

The issue is with your project which is not able to complete maven build. Steps to follow :

问题在于您的项目无法完成 maven 构建。要遵循的步骤:

  1. Right Click Application and RunAs maven install.
  2. If you get any error while reaching the repos online try giving the proxies in settings.xml under your .m2 directory.Check this link for setting proxies for maven build.
  3. Once done , try doing a Update Project by Right Click Project , Maven->Update Maven Project and select codebase and do check the Force Update of Snapshot/Release check box.
  1. 右键单击应用程序和 RunAs maven 安装。
  2. 如果在线访问 repos 时遇到任何错误,请尝试在 .m2 目录下的 settings.xml 中提供代理。检查此链接以设置 maven build 的代理
  3. 完成后,尝试通过右键单击 Project ,Maven->Update Maven Project 并选择代码库并选中 Force Update of Snapshot/Release 复选框来执行更新项目。

This will update your maven build and will surely remove your errors with pom.xml

这将更新您的 Maven 构建,并且肯定会使用 pom.xml 删除您的错误

回答by prachi shah

Project->maven->Update Project->tick all checkboxes expect offlineand error is solved soon.

项目-> maven-> 更新项目-> 勾选所有希望脱机的复选框,错误很快得到解决。

回答by David Caceres

Rigth button on your project -> Maven -> Update

项目上的右侧按钮 -> Maven -> 更新

回答by siddagrl

In my case the problem was with the java version mismatch of pom.xml (java 1.8) and environment variables JAVA_HOME/JDK_HOME (java 1.7). After pointing environment variables JAVA_HOME & JDK_HOME to Java 1.8, the issue got resolved.

就我而言,问题在于 pom.xml (java 1.8) 和环境变量 JAVA_HOME/JDK_HOME (java 1.7) 的 java 版本不匹配。将环境变量 JAVA_HOME 和 JDK_HOME 指向 Java 1.8 后,问题得到解决。

回答by Panthro

If you're using docker-machine(docker on Windowsor OSX).

如果您正在使用docker-machineWindowsOSX上的docker)。

Currently docker-machine has a bug that it loses internet connection if you switch between wifi networks or wifi and cable.

当前 docker-machine 有一个错误,如果您在 wifi 网络或 wifi 和电缆之间切换,它会丢失互联网连接。

Make sure you restart your docker-machine

确保重新启动 docker-machine

usually: docker-machine restart default

通常: docker-machine restart default

回答by Atul Jain

Downgrade your version

降级您的版本

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version><change this version></version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

Build and undo the version, Build. 2.1.6.RELEASE to 1.3.3.RELEASE Build Undo 1.3.3 to 2.1.6 Build (in my case problem solved) It helped us.

构建和撤消版本,构建。2.1.6.RELEASE to 1.3.3.RELEASE Build Undo 1.3.3 to 2.1.6 Build(在我的情况下问题解决了)它帮助了我们。

回答by Marcos Gon?alves

As people already mentioned, it could be internet problems or proxy configuration.
I found this question when I was searching about the same problem. In my case, it was proxy configuration.
Answers posted here didn't solve my issue, because every link suggest a configuration that shows the username and passoword and I can't use it.
I was searching about it elsewere and I found a configuration to be made on settings.xml, I needed to make some changes. Here is the final code:

正如人们已经提到的,这可能是互联网问题或代理配置。
当我搜索同样的问题时,我发现了这个问题。就我而言,它是代理配置。
此处发布的答案并没有解决我的问题,因为每个链接都建议显示用户名和密码的配置,而我无法使用它。
我正在搜索它,但我发现要在 settings.xml 上进行配置,我需要进行一些更改。这是最终的代码:

<profiles>
    <profile>
       <id>MavenRepository</id>
           <repositories>
            <repository>
                <id>central</id>
                <url>https://repo1.maven.org/maven2</url>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <releases>
                    <enabled>true</enabled>
                </releases>
            </repository>
        </repositories>
    </profile>
</profiles>

<activeProfiles>
    <activeProfile>MavenRepository</activeProfile>
</activeProfiles>

I hope be useful.

我希望有用。

回答by Gaurav

If you are using docker service and you have switched to other network. You need to restart docker service.

如果您使用的是 docker 服务并且您已经切换到其他网络。您需要重新启动 docker 服务。

service docker restart

服务 docker 重启

This solved my problem in docker.

这解决了我在 docker 中的问题。