找不到依赖项“org.springframework.boot:spring-boot-starter-data-jpa:2.5.3”

sat*_*jha 2 java spring maven spring-boot

我是 Spring Boot 的新手,刚刚开始探索它。我遇到了这个问题,其中 intellij ide 在 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 https://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.5.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>Spring-boot-tutorial</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Spring-boot-tutorial</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </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-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>2.5.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

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

            </plugin>
        </plugins>
    </build>

</project>
Run Code Online (Sandbox Code Playgroud)

如果有人能够了解这些依赖关系问题在 Spring Boot 中如何发生以及如何追踪它们,那将非常有帮助。请注意,我对 spring-boot-maven-plugin 也有类似的问题,所以我只是在其下面添加了版本代码以使其正常工作。相同的版本添加对 spring-boot-starter-data-jpa 不起作用。

小智 6

重新加载项目可能会有所帮助。脚步

  1. 右键单击该项目
  2. 转到“maven”选项
  3. 单击“重新加载项目”

  • 如果这不起作用,请尝试“文件”-&gt;“使缓存无效”-&gt;“选择所有选项”。 (2认同)