解决springboot因为Error creating bean with name ‘dataSource‘ defined in class path resource。。报错问题

1、解决springboot因为Error creating bean with name 'dataSource' defined in class path resource。。报错问题

2、错误代码详情:
Error creating bean with name 'dataSource' defined in class path resource [com/alibaba/druid/spring/boot/autoconfigure/DruidDataSourceAutoConfigure.class]: Bean instantiation via factory method failed;  nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql. DataSource]: Factory method 'dataSource' threw exception;  nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedDataBinder
译文创建类路径resource中定义的名为“dataSource”的bean时出错:通过工厂方法实例化bean失败;嵌套的异常是org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql. sql]。:工厂方法' DataSource '抛出异常;嵌套异常是java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedDataBinder
3、在刚开始我搜索网上大部分答案是需要配置一个@SpringBootApplication(exclude={DruidDataSourceAutoConfigure.class, SecurityAutoConfiguration.class})注解,尝试了无数遍都没解决,还是报上面的错误,最后无奈摸索了两个多小时,发现是我的mybatis和druid坐标,是这两个坐标版本冲突造成的问题,当我刚开始使用的是mabatis版本3.4.3,druid版本为1.0.1,就会提示这样错误,通过查询得知,mybatis的3.4.3版本对应的druid版本为1.2.6,改过来后,运行正常,如图:


 

 这两个版本可以不发生冲突

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值