Non-resolvable import POM Failure to find

Non-resolvable import POM Failure to find

我在父 pom 中尝试了 spring 类似引导的模块,现在出现错误

[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Non-resolvable import POM: Failure to find org.springframework.boot:spring-boot-dependencies:pom:2.0.0.M6 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced @ line 30, column 19
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project mydomain.project:main-project:1.0-SNAPSHOT (D:\gitProjects\main-server\sources\pom.xml) has 1 error
[ERROR]     Non-resolvable import POM: Failure to find org.springframework.boot:spring-boot-dependencies:pom:2.0.0.M6 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced @ line 30, column 19 -> [Help 2]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

我尝试删除 .m2 本地存储库中的我的项目

我有带有 2 个模块的 Maven 项目(简单 java 和 spring 启动)。我从 spring boot 中提取 parent 到主 pom,如 dependensyManagment 并将 paren 设置为 spring boot - 主项目。之后我得到这个错误

我还原更改并且一切正常。步步为营我晕倒点当都暗恋

  1. 我将其添加到主 pom
<dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>2.0.0.M6</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>   </dependencyManagement>
  1. 在spring开机我改这个
<parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.0.0.M6</version>
      <relativePath/> <!-- lookup parent from repository -->
  </parent>

对此:

<parent>
        <artifactId>main-project</artifactId>
        <groupId>main.project</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

版本 2.0.0.M6 不在存储库 http://repo.maven.apache.org/maven2. If you wan't to use this version you have to use the maven repo http://repo.spring.io/milestone 中。所以将它添加到您的 POM 文件中:

<repositories>
    <repository>
        <id>spring-milestone-repo</id>
        <url>http://repo.spring.io/milestone/</url>
    </repository>
</repositories>

我建议您使用最新发布的 spring-boot (1.5.8.RELEASE) 版本,而不是里程碑版本。我不知道你的 POM 是什么样子,但你可以用不同的方式在你的 POM 中定义 spring 引导:

1。使用 Spring 引导父 POM

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.8.RELEASE</version>
</parent>

然后您可以添加您希望使用的依赖项,例如:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

参见:https://spring.io/guides/gs/spring-boot/

2。在 Dependency-Management 中声明 Spring-Boot

如果您已经在使用自己的父 POM,您还可以在 POM 中导入 spring 引导依赖管理:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>1.5.8.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

与变体 #1 相同,您可以在之后声明您希望使用的 spring 引导的依赖项。

检查您是否没有添加 spring 已经 spring-boot 作为父项的启动依赖项。我就是这样。