不可解析的导入POM未找到

ip6*_*696 5 java dependency-management maven spring-boot

我在父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
Run Code Online (Sandbox Code Playgroud)

我尝试在.m2本地仓库中删除myproject

我有2个模块的maven项目(简单的java和spring boot).我将父启动从春季启动提取到主要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>
Run Code Online (Sandbox Code Playgroud)
  1. 在春季靴子我改变了这一点
<parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.0.0.M6</version>
      <relativePath/> <!-- lookup parent from repository -->
  </parent>
Run Code Online (Sandbox Code Playgroud)

对此:

<parent>
        <artifactId>main-project</artifactId>
        <groupId>main.project</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
Run Code Online (Sandbox Code Playgroud)

ph1*_*h1l 7

版本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>
Run Code Online (Sandbox Code Playgroud)

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

1.使用Spring Boot父POM

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.8.RELEASE</version>
</parent>
Run Code Online (Sandbox Code Playgroud)

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

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

请参阅: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>
Run Code Online (Sandbox Code Playgroud)

与变体#1相同,您可以在之后声明要使用的spring boot的依赖项.