Spring boot starter parent 2.0.0 未找到依赖项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45480451/
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 01:28:24  来源:igfitidea点击:

Spring boot starter parent 2.0.0 not found dependency

springmavenspring-boot

提问by Tiago Casinhas

I decided to update my spring-boot-starter-parent to version 2.0.0.M1 in order to use it with Spring Core 5.0.0.RC1.

我决定将 spring-boot-starter-parent 更新到 2.0.0.M1 版本,以便与 Spring Core 5.0.0.RC1 一起使用。

But, i am having issues downloading the dependency from the Spring milestone repository.

但是,我在从 Spring 里程碑存储库下载依赖项时遇到问题。

My pom.xml

我的 pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.test.testapplication</groupId>
<artifactId>application</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.0.M1</version>
</parent>

<repositories>
    <repository>
        <id>repository.spring.milestone</id>
        <name>Spring Milestone Repository</name>
        <url>http://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.test.testplugin</groupId>
            <artifactId>plugin</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.test.testutils</groupId>
            <artifactId>utils</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>

I have a "clean sheat" .m2 settings.xml, and i have cleaned my local repository, and made sure i can connect to the spring milestone repository.

我有一个“干净的外壳”.m2 settings.xml,我已经清理了我的本地存储库,并确保我可以连接到 spring 里程碑存储库。

[INFO] ------------------------------------------------------------------------
[INFO] Building application 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-maven-plugin/2.0.0.M1/spring-boot-maven-plugin-2.0.0.M1.pom
[WARNING] The POM for org.springframework.boot:spring-boot-maven-plugin:jar:2.0.0.M1 is missing, no dependency information available
Downloading: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-maven-plugin/2.0.0.M1/spring-boot-maven-plugin-2.0.0.M1.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
.
.
.

[INFO] plugin ............................................. SUCCESS [  0.327 s]
[INFO] application ........................................ FAILURE [  0.881 s]
[INFO] webapp ............................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
.
.
.
.
.

[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.springframework.boot:spring-boot-maven-plugin:2.0.0.M1 or one of its dependencies could not be resolved: Could not find artifact org.springframework.boot:spring-boot-maven-plugin:jar:2.0.0.M1 in central (https://repo.maven.apache.org/maven2) -> [Help 1]

回答by sunkuet02

Add Spring Plugin Release Repoto Plugin-Repositories. So that it can find the spring-boot-maven-plugin-2.0.0.M1.jar. I have seen that it contains in that repo

Spring Plugin Release Repo添加到Plugin-Repositories. 以便它可以找到spring-boot-maven-plugin-2.0.0.M1.jar. 我已经看到它包含在那个 repo 中

Add the below lines under <project>tag as like:

<project>标签下添加以下几行,如下所示:

<project>
<!------ others lines -->
    <pluginRepositories>
        <pluginRepository>
            <id>repository.spring.release</id>
            <name>Spring GA Repository</name>
            <url>https://repo.spring.io/plugins-release/</url>
        </pluginRepository>
    </pluginRepositories>
</project>

EDIT

编辑

As I have no com.test.testplugin, I have checked with the followings. Please, remove the <dependencyManagement>and put <dependencies>under <project>. Final pom.xmllooks like:

由于我没有com.test.testplugin,我已经检查了以下内容。请取下<dependencyManagement>并放在<dependencies><project>。最终pom.xml看起来像:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.test.testapplication</groupId>
    <artifactId>application</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.M1</version>
    </parent>

    <pluginRepositories>
        <pluginRepository>
            <id>repository.spring.release</id>
            <name>Spring GA Repository</name>
            <url>https://repo.spring.io/plugins-release/</url>
        </pluginRepository>
    </pluginRepositories>

    <repositories>
        <repository>
            <id>repository.spring.milestone</id>
            <name>Spring Milestone Repository</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>

回答by Eric Wang

To use spring-boot milestone versions, add following to pom.xml, between <project></project>:

要使用 spring-boot 里程碑版本,请在pom.xml之间添加以下内容<project></project>

<repositories>
    <!-- for spring milestone -->
    <repository>
        <id>spring.milestone</id>
        <url>http://repo.spring.io/milestone</url>
    </repository>
</repositories>
<pluginRepositories>
    <!-- for spring milestone -->
    <pluginRepository>
        <id>spring.milestone</id>
        <url>http://repo.spring.io/milestone</url>
    </pluginRepository>
</pluginRepositories>

回答by Ashutosh S

For 

  `<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.M7</version>
    </parent>`

Putting below repositories tags in pom.xml , it helped me building project .

将 repositories 标签放在 pom.xml 下方,它帮助我构建项目。

<repositories>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>repository.springframework.maven.release</id>
        <name>Spring Framework Maven Release Repository</name>
        <url>http://maven.springframework.org/milestone/</url>
    </repository>
    <repository>
        <id>org.springframework</id>
        <url> http://maven.springframework.org/snapshot</url>
    </repository>
    <repository>
        <id>spring-milestone</id>
        <name>Spring Maven MILESTONE Repository</name>
        <url>http://repo.spring.io/libs-milestone</url>
    </repository>
    <repository>
        <id>spring-release</id>
        <name>Spring Maven RELEASE Repository</name>
        <url>http://repo.spring.io/libs-release</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

回答by Edenshaw

I didn't have a "clean sheet" settings.xmlbecause I have a personal mirror URL in place. The only way to fix this issue was to include @Hantsy answer in my settings.xmlinstead of the pom.xml

我没有“干净的床单”,settings.xml因为我有一个个人镜像 URL。解决此问题的唯一方法是将@Hantsy 答案包含在 mysettings.xml而不是pom.xml

回答by QiuYi

If you are in China, you can fix this problem by modifying the settings.xmlfile like this:

如果你在 CN ,你可以通过settings.xml像这样修改文件来解决这个问题:

<mirror>
    <id>nexus-aliyun</id>
    <mirrorOf>*</mirrorOf>
    <name>Nexus aliyun</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

settings.xmlpath of mine:C:\Program Files\apache-maven-3.6.0\conf\settings.xml

settings.xml我的路径:C:\Program Files\apache-maven-3.6.0\conf\settings.xml

回答by secret super star

The question is bit old, but I am updating here hoping that it might help someone.

这个问题有点老了,但我在这里更新希望它可以帮助某人。

In my case, work offline has been checkedand hence I was getting error.

就我而言,离线工作已被检查,因此我收到错误消息。

Here is the fix I have made. in Mac, navigate to IntelliJ menu and select preferences or short cut key(Command + ,).

这是我所做的修复。在 Mac 中,导航到 IntelliJ 菜单并选择首选项或快捷键(Command + ,)。

Search mavenand select. then uncheckwork offlineif it is checked already.

搜索maven并选择。如果已经检查过,则uncheck脱机工作

enter image description here

在此处输入图片说明

回答by velocity

to fix this, try to click the reimport all maven projects button: enter image description here:

要解决此问题,请尝试单击重新导入所有 maven 项目按钮 在此处输入图片说明::

回答by Hantsy

Add the following into your pom.xmlfile.

将以下内容添加到您的pom.xml文件中。

 <repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

I suggest you update the Spring Boot version to the latest to get newest dependencies, currently it is 2.0.0.M6 which includes Spring 5.0.1.RELEASE in its dependencies management.

我建议您将 Spring Boot 版本更新到最新以获取最新的依赖项,目前它是 2.0.0.M6,其中在其依赖项管理中包含 Spring 5.0.1.RELEASE。

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

Or generate a new Spring Boot 2.0 based project from Spring Initializer, all dependencies will be resolved.

或者从Spring Initializer生成一个新的基于 Spring Boot 2.0 的项目,所有的依赖都会被解决。