[spring error] Failed to bind properties under 'spring.datasource' to javax.sql.DataSource:

在升级Spring Boot版本后,遇到启动时无法绑定'spring.datasource'到javax.sql.DataSource的错误。错误源于properties文件中数据库配置。解决方案是移除特定的配置项,问题得到解决。
摘要由CSDN通过智能技术生成

使用spring 连接数据库时,在升级spring boot版本之后,启动项目报错如下:


Failed to bind properties under 'spring.datasource' to javax.sql.DataSource:

    Property: spring.datasource.driverclassname
    Value: org.postgresql.Driver    
    Origin: class path resource [application-postgres.properties]:7:35
    Reason: Failed to load driver class org.postgresql.Driver     in either of HikariConfig class loader or Thread context classloader

在property文件里面对数据库的定义如下:

spring.datasource.url=jdbc:postgresql://localhost:5432/test
spring.datasource.username=user
spring.datasource.password=ped
spring.datasource.driverClassName=org.postgresql.Driver    

数据库DataSource bean的定义如下:


@Configuration
@Profile("postgres")
public class SourceDataSourceConfigurationLocal {
    @Bean
    @C
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值