java出现无法解析包,java – 无法解析类或包’h2′

我为我的网络应用程序预制了后端.

在我的项目(SpringBoot Maven)中,我想添加h2日期库.

根据网站的教程:

>已添加到application.properties

server.port = 8088

spring.h2.console.enabled=true

spring.h2.console.path=/h2

spring.datasource.url=jdbc:h2:mem:testdb

spring.datasource.username=sa

spring.datasource.password=

spring.datasource.driverClassName=org.h2.Driver //h2 seems to be NOT found

spring.jpa.show-sql=true

>添加了对pom.xml的依赖项

org.springframework.boot

spring-boot-starter-data-jpa

com.h2database

h2

问题:

在application.properties中:“无法解析类或包’h2’”

全面检查:“检查Spring Boot应用程序.properties配置文件.突出显示未解析和弃用的配置键和无效值.仅适用于Spring Boot 1.2或更高版本.”

当然,我的Spring Boot高于1.2(1.5.8).我在网上发现了类似的问题,但“重新编码依赖”不起作用,所以我仍然没有解决方案:).请帮忙.

解决方法:

看起来问题出在您的pom文件中.请查看我在您的application.properties文件中检查过的pom.xml文件.

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

com.mberazouski.stackoverflow

spring-boot-hibernate

0.0.1-SNAPSHOT

jar

spring-boot-hibernate

Demo project for Spring Boot And Hibernate

org.springframework.boot

spring-boot-starter-parent

2.0.3.RELEASE

UTF-8

UTF-8

1.8

org.springframework.boot

spring-boot-starter-data-jpa

org.springframework.boot

spring-boot-starter-web

com.h2database

h2

runtime

一旦你的春季启动开始,检查h2-console:

http://localhost:8088/h2

N1yHH.png

希望这会有所帮助.

附:如果您不知道我建议您使用http://start.spring.io/来生成您的项目.在那里,您可以选择您计划使用的任何组件.更多关于这一点,你可以阅读例如here.

标签:java,spring,spring-boot,maven,h2

来源: https://codeday.me/bug/20190910/1799699.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值