我正在使用Springboot构建后端应用程序支持,并尝试使用Spring内置的h2数据库。然而,当我在pom.xml中添加下面的h2依赖项时,它出错了。
错误
读取com.h2database:h2:jar:1.4.200的工件描述符失败,未找到依赖项'com.h2database:h2:1.4.200'
pom.xml
4.0.0 org.springframework. Boot spring-boot-starter-parent 2.3.3.RELEASE com.krishnaQuiz Krishna-Quiz 0.0.1-SNAPSHOT Krishna-Quiz Krishna Quiz 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>
=======================
请帮帮忙
2条答案
按热度按时间0h4hbjxa1#
我也有同样的问题...在pom.xml中指定H2版本并等待更新。
测试文件中会出现一个错误,如果你使用eclipse,只需打开它并更新导入“CTRL+SHIFT+O”即可。
toiithl62#
我有同样的问题在我的情况下,我解决了它-在intellij去maven和简单地重新加载maven项目,它将工作,或者你可以使用mvn清理安装命令