springcloud解决运行出现Failed to determine a suitable driver class
找了一下午的大坑,终于被解决了!!!!
首先项目之前一直都是好好地,然后突然有个模块启动报错,错误如下:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: GlobalConfigUtils setMetaData Fail ! Cause:com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: Get proxy targetObject exception ! Cause:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver classat org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1287) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1511) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]... 43 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: GlobalConfigUtils setMetaData Fail ! Cause:com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: Get proxy targetObject exception ! Cause:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver classat org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]... 56 common frames omitted
Caused by: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: GlobalConfigUtils setMetaData Fail ! Cause:com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: Get proxy targetObject exception ! Cause:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver classat com.baomidou.mybatisplus.core.toolkit.ExceptionUtils.mpe(ExceptionUtils.java:51) ~[mybatis-plus-core-3.0.7.jar:3.0.7]at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.buildSqlSessionFactory(MybatisSqlSessionFactoryBean.java:603) ~[mybatis-plus-extension-3.0.7.jar:3.0.7]at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.afterPropertiesSet(MybatisSqlSessionFactoryBean.java:387) ~[mybatis-plus-extension-3.0.7.jar:3.0.7]at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.getObject(MybatisSqlSessionFactoryBean.java:684) ~[mybatis-plus-extension-3.0.7.jar:3.0.7]at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration.sqlSessionFactory(MybatisPlusAutoConfiguration.java:166) ~[mybatis-plus-boot-starter-3.0.7.jar:3.0.7]at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration$$EnhancerBySpringCGLIB$$af14ae20.CGLIB$sqlSessionFactory$1(<generated>) ~[mybatis-plus-boot-starter-3.0.7.jar:3.0.7]at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration$$EnhancerBySpringCGLIB$$af14ae20$$FastClassBySpringCGLIB$$200f7dae.invoke(<generated>) ~[mybatis-plus-boot-starter-3.0.7.jar:3.0.7]at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]at com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration$$EnhancerBySpringCGLIB$$af14ae20.sqlSessionFactory(<generated>) ~[mybatis-plus-boot-starter-3.0.7.jar:3.0.7]at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]... 57 common frames omittedProcess finished with exit code 1
各种的Bean注入失败啊,sqlsession注入失败等等一堆让人看了就头皮发麻。。。。
Caused by: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: GlobalConfigUtils setMetaData Fail ! Cause:com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: Get proxy targetObject exception ! Cause:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
主要还是因为最后一个Caused By 引起的错误,mp配置数据源,失败了。。也搜了一些关于Bean,数据源注入失败的文档。。
说一下我的问题,最后才知道是因为我的yml文件肯定就没有编译到target中
然后我就复制了一份application.yml到target中
启动成功
target中没有application文件的小伙伴也可以和我一样复制一份文件到traget修改一下,也可以找一下其他办法
以下是application文件在target中,但是没有bean和数据源,可能存在的问题
1.看看yml文件中的数据源配置是否正确
2.Contrller,Service,Mapper上是否都加了注解
3.主启动类上是否开启了包扫描,mapper扫描
4.如果mapper.xml文件放在了resources下,在yml中配置xml的location路径,如果放在了java下面在yml中配置的同时还需要添加依赖
//yml配置
mybatis-plus:configuration:log-impl: org.apache.ibatis.logging.stdout.StdOutImplmapper-locations: classpath:com/atwang/eduRlogin/mapper/xml/*.xml//依赖<resources><!-- 编译main下面的xml文件和.properties文件--><resource><directory>src/main/java</directory><includes><include>**/*.properties</include><include>**/*.xml</include></includes><filtering>false</filtering></resource><!-- 编译resources下面的配置文件和xml文件--><resource><directory>src/main/resources</directory><includes><include>**/*.properties</include><include>**/*.xml</include></includes><filtering>false</filtering></resource></resources>
5.如果以上都已经配置完成,还是没有数据源的话,删除target包清理一下缓存,然后maven中install一下
以上就是本次文章的全部内容啦,如果有小伙伴还有其他的解决方案,欢迎在评论区留言。。第一次写CSDN文章,主要是找这个问题蛮久的,,写篇文章记录一下顺便看看如果能够帮助到其他人就更好了。。
springcloud解决运行出现Failed to determine a suitable driver class相关推荐
- 报错解决:Reason: Failed to determine a suitable driver class
背景: 导入别人的项目,却报错: Error starting ApplicationContext. To display the conditions report re-run your app ...
- 若依微服务版在Windows上通过jar包运行业务模块时提示:Failed to determine s suitable driver class
场景 若依微服务版后台服务通过jar包部署到Windows服务器: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/10962333 ...
- spring boot测试方法报Failed to determine a suitable driver class的解决办法
时间:2022年2月2日 项目:spring boot整合mybatis-plus 错误类型:Failed to determine a suitable driver class 错误原因:pom. ...
- 完美解决Failed to determine a suitable driver class的问题
文章目录 1. 复现问题 2. 分析问题 3. 解决问题 4. 总结问题 1. 复现问题 今天在启动项目时,遇到如下问题: *************************** APPLICATIO ...
- Error creating bean with name 'dataSource'...Failed to determine a suitable driver class
场景: 新建的spring-boot maven mybatis工程,运行时报以下异常 16:04:10.751 [main] ERROR org.springframework.test.conte ...
- IDEA报错 Failed to determine a suitable driver class
文章目录 现象 解决 接触标志resources目录 重新标志resources目录 现象 在做项目的过程中,需要区分几套环境,一般SpringBoot项目的配置文件也会进行分离,如下: applic ...
- Java DataSourceBeanCreationException: Failed to determine a suitable driver class问题解决
问题描述: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationExcepti ...
- Springboot 抛出Failed to determine a suitable driver class异常原因
Springboot 抛出Failed to determine a suitable driver class异常原因 参考文章: (1)Springboot 抛出Failed to determi ...
- SpringBoot 启动失败 Failed to determine a suitable driver class 问题解决方案
SpringBoot 启动失败 Failed to determine a suitable driver class 问题解决方案 参考文章: (1)SpringBoot 启动失败 Failed t ...
最新文章
- Linux tcpdump命令详解与Wireshark
- RHCS图形界面建立GFS共享上
- java中的权限修饰符_Java的权限修饰符的区别和用法总结
- python基础教程是什么意思-python基础教程都有什么?
- 第十二届蓝桥杯大赛软件赛省赛第二场【C++B组】
- Knative Serving 进阶: Knative Serving SDK
- 何为消息队列,为何使用消息队列,有什么消息队列插件
- DockOne微信分享(八十四):Docker在B站的实施之路
- 个人应用开发详记. (三)
- 水土保持功能评估中k值的计算公式
- (81)Vivado实现约束过程
- ODOO v10.0 自动生成财务凭证的科目设置
- 用AI帮你画新年贺卡:只需输入几个单词,就能模仿大师名作
- [RHEL5企业级Linux服务攻略]--第1季 Linux服务器的搭建与测试
- C语言基础课第三次作业
- java 手机类测试
- linux安装vim不成功,centos安装vim失败解决
- Linux下的Scala安装
- Movavi Video Suite 使用教程|如何刻录DVD ?使用Movavi Video Suite!
- Kindle使用指南