【发布时间】:2018-11-26 03:49:18
【问题描述】:
我为我的网络应用程序开发后端应用程序。 在我的项目(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 文件中添加了以下依赖项:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> </dependency>
问题:
在application.properties中:“无法解析类或包'h2'”
全面检查:“检查 Spring Boot 应用程序 .properties 配置文件。突出显示未解析和已弃用的配置键和无效值。仅适用于 Spring Boot 1.2 或更高版本。”
当然,我的 Spring Boot 高于 1.2 (1.5.8)。 我在网络上发现了类似的问题,但是“重新加载依赖项”不起作用,所以我仍然没有解决方案:)。请帮忙。
【问题讨论】:
-
你不需要Maven pom.xml中的版本吗?比如..mvnrepository.com/artifact/com.h2database/h2/1.4.197 - 也可能在春季启动级别......
标签: java spring maven spring-boot h2