不可解析的导入POM未找到

时间:2017-11-14 07:46:20

标签: java maven spring-boot dependency-management

我在父pom中尝试像模块一样的弹簧启动,现在我收到了错误

[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 local repo

中删除myproject

我有2个模块的maven项目(简单的java和spring boot)。我将父启动从春季启动提取到主要pom,如dependensyManagment,并将paren设置为spring boot - 主项目。之后我收到此错误

我还原变化,一切正常。所有粉碎时,我一步一步地点着点。

  1. 我将此添加到主pom
  2. <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. 在春季启动时我改变了这个
    2. <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 :(得分:6)

版本2.0.0.M6不在repo http://repo.maven.apache.org/maven2中。如果您不想使用此版本,则必须使用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中定义弹簧启动:

1。使用Spring Boot父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。在依赖管理中声明Spring-Boot

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

<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 boot的依赖项。

答案 1 :(得分:0)

检查是否没有添加已经具有spring-boot作为父项的spring boot依赖项。那是我的情况。