Failed to bind properties under ‘spring.datasource.type’ to java.lang.Class的解决方法

本文详细解析了SpringBoot应用程序在启动过程中遇到的关于数据源类型绑定失败的问题,具体表现为无法将Druid数据源字符串类型转换为javax.sql.DataSource类。通过在pom.xml文件中正确添加Druid和Fastjson依赖,成功解决了这一技术难题。

Failed to bind properties under ‘spring.datasource.type’ to java.lang.Class<javax.sql.DataSource>.
问题详情如下:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-06-04 8:27:01.386 ERROR 11568 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to bind properties under 'spring.datasource.type' to java.lang.Class<javax.sql.DataSource>:

    Property: spring.datasource.type
    Value: com.alibaba.druid.pool.DruidDataSource
    Origin: class path resource [application.properties]:25:24
    Reason: No converter found capable of converting from type [java.lang.String] to type [java.lang.Class<javax.sql.DataSource>]

Action:

Update your application's configuration

Disconnected from the target VM, address: '127.0.0.1:51477', transport: 'socket'

Process finished with exit code 0

解决方法:
配置文件pom.xml中添加依赖,问题解决

<!-- 引入Druid依赖,阿里巴巴所提供的数据源 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.1.13</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>
评论 4
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值