找不到项目 'org.springframework.boot:spring-boot-starter-parent:2.4.0'

Project 'org.springframework.boot:spring-boot-starter-parent:2.4.0' not found

我正在遵循此指南:https://spring.io/guides/gs/serving-web-content/,

<?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>

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

    <groupId>org.example</groupId>
    <artifactId>plats-bruts</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
    <java.version>1.8</java.version>
</properties>

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

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

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

</project>

但是我在 pom 上有这个问题:

Project 'org.springframework.boot:spring-boot-starter-parent:2.4.0' not found

但它在这里 https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent/2.4.0

Spring Boot的starter parent pom肯定是does exist in Maven Central.

我使用 Maven 3.6.3 复制了您的 pom.xml 和 运行 mvn test。所有必需的库,包括父 pom 都被下载得很好。您可能需要查看 ~/.m2/settings.xml 文件以查看是否有任何代理正在阻止您连接到 Maven Central。

可能您正在尝试直接 运行 mvn spring-boot:run

您可以使用包装器代替 cf。 ./mvnw spring-boot:run 这应该可以解决您的问题。

我刚刚运行遇到了类似的问题。我正在使用 IntelliJ IDEA Ultimate 2020.2。版本号2.4.0是红色的,消息跟你的一样

选择文件 -> 使缓存无效/重新启动...并选择无效并重新启动选项解决了这个问题。我想这只是一个陈旧的缓存。

对我有用的是重建和远程缓存,然后是本地缓存。这是我遵循的步骤(在 Mac 上,请翻译成您的目标环境):

  1. 转到首选项菜单:即:IntelliJ IDEA > 首选项
  2. 在构建工具下:即:“构建、执行、部署”> 构建工具
  3. Select 存储库:即:Maven > 存储库
  4. 注意远程和本地存储库,以及更新按钮
  5. Select 每个存储库并单击更新。这将需要一段时间,具体取决于您的互联网速度,但它将对损坏的下载和陈旧的 Maven 缓存进行全面检查

我正在使用 IntelliJ IDEA Ultimate 2021.1.1。版本号 2.5.4 Spring 开机。 I just restarted Intellij and the error was fixed.

只需在 IDE 中重新加载您的 Maven 项目。它会起作用。

在我的情况下 mvn clean 而不是 mvn package 帮助我解决了同样的问题。