我正在使用 Springboot 构建后端应用程序支持,并尝试使用 Spring 内置的 h2 数据库。但是,当我在 pom.xml 中添加以下 h2 依赖项时,出现错误。
4.0.0 org.springframework.boot spring-boot-starter-父级 2.3.3.发布 com.krishnaQuiz 克里希纳测验 0.0.1-快照 克里希纳测验 克里希纳测验 UI
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<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>
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
===========================
请帮忙
我遇到了同样的问题...在 pom.xml 中指定 H2 版本并等待更新。
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
<scope>runtime</scope>
</dependency>
测试文件中会出现错误,如果使用eclipse,只需打开它并更新导入“CTRL+SHIFT+O”即可。
我在我的案例中遇到了同样的问题,我通过以下方式解决了它:在intellij中转到maven并简单地重新加载它将工作的maven项目,或者您可以使用mvn clean install命令