【发布时间】:2021-07-27 23:34:04
【问题描述】:
我是 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>
如果有人能了解这些依赖问题在 Spring Boot 中是如何发生的以及如何跟踪它们,那将非常有帮助。 请注意,我与 spring-boot-maven-plugin 有类似的问题,所以我只是在它下面添加了版本代码以使其工作。相同的版本添加对 spring-boot-starter-data-jpa 不起作用。
【问题讨论】:
-
尝试重新打开 IDE 并使用
mvn install && spring-boot:run。请让我知道这是否能解决您的问题 -
我确实使 intellij 的缓存无效,并且 pom.xml 中不再存在那些红色标记。
-
@Reborn 我还有一个关于编译如何工作的问题,因为即使在 pom.xml 中有那些红色标记,编译也会发生。
-
如果您在安装依赖项后仍然在 pom.xml 中看到红色标记,则可能是另一个问题。仔细检查您如何导入项目(它应该作为 Maven 导入)。之后,确保您右键单击该项目并选择“同步项目”;
-
这个错误你忘了实际包含错误。
标签: java spring spring-boot maven