【发布时间】:2023-03-26 10:50:01
【问题描述】:
我有一个带有 spring boot 2.0.3.RELEASE 的 Spring Boot JPA 应用程序并连接到 PostgreSQL,当我运行该应用程序时,我收到以下错误消息:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
数据库连接属性:
spring:
datasource:
url: jdbc:postgresql://localhost:5432/testS
username: postgres
password: postgres123
driver-class-name: org.postgresql.Driver
依赖关系:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
堆栈跟踪:
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
我该如何解决这个问题?
【问题讨论】:
-
分享 stacktrace 会有帮助的
-
@GauravSrivastav 完成
-
尝试在数据源中使用属性:
dataSourceClassName=org.postgresql.ds.PGSimpleDataSource -
还是一样的问题
标签: java spring spring-boot jpa