【发布时间】:2019-05-25 02:56:57
【问题描述】:
我用 jpa/postgres 构建了一些简单的 spring boot 项目。
但是当我调试这个项目时,错误说
配置数据源失败:未指定“url”属性,无法配置嵌入式数据源。
原因:无法确定合适的驱动程序类
但是在我的 application.properties 中有 url。
spring.datasource.url=jdbc:postgresql://localhost:5432/oauth?currentSchema=oauth
spring.datasource.username=SOME_USER_NAME
spring.datasource.password=SOME_PASSWORD
spring.datasource.driverClassName=org.postgresql.Driver
spring.jpa.hibernate.ddl-auto=validate
#hibernate
spring.jpa.database = postgresql
spring.jpa.show-sql = true
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
有人知道吗?
如果验证比调试麻烦,不要说“未指定 url 属性”。
我的 application.properties 名称为“application-test.properties”,在调试配置集“test”中,还记录说“配置文件测试当前处于活动状态”。
看起来属性不匹配,但记录说配置文件匹配。
这让我很困惑..
【问题讨论】:
-
你能分享一些与此相关的回购吗?
-
您的 pom.xml 中有 de postgres 依赖项?为什么你的 application.properties 中需要 spring.jpa.database ?
-
哦,这是 gradle 项目,我像这样导入 postgres。当 spring boot 设置时,我选择 postgres 而不是 build.gradle 像这样
runtime('org.postgresql:postgresql')
标签: java spring postgresql spring-boot