栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

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

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

解决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,改过来后,运行正常,如图:


 

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/849893.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号