springboot、mybatis-plus配置多数据源的坑的记录

利用mybatis-plus配置多数据源时,根据官方文档配置好后,服务启动报错:

2020-08-21 20:38:05.346 DEBUG 19584 - [ost-startStop-1] com.ld.base.LordarLogFilter              : Initializing filter 'lordarLogFilter'
2020-08-21 20:38:05.346 DEBUG 19584 - [ost-startStop-1] com.ld.base.LordarLogFilter              : Filter 'lordarLogFilter' configured successfully
2020-08-21 20:38:05.544  INFO 19584 - [           main] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource
2020-08-21 20:38:05.915  WARN 19584 - [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'syncOrder': Unsatisfied dependency expressed through field 'transactionlogSfaMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'transactionlogSfaMapper' defined in file [E:\lordar\loreal-dp-online\dp-ticket\deps\dp-ticket-mapper\target\classes\com\ld\mapper\dao\TransactionlogSfaMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/alibaba/druid/spring/boot/autoconfigure/DruidDataSourceAutoConfigure.class]: Invocation of init method failed; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "dev" are currently active).
2020-08-21 20:38:05.915  INFO 19584 - [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2020-08-21 20:38:06.015  INFO 19584 - [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2020-08-21 20:38:06.022 ERROR 19584 - [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

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

Description:

Cannot determine embedded database driver class for database type NONE

Action:

If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "dev" are currently active).

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

Process finished with exit code 1

寻找了好久,在yml文件加上一个配置解决问题:

    autoconfigure:
#        为了某些版本的springboot  @SpringBootApplication(exclude= {DataSourceAutoConfiguration.class}) 无法生效
#        @SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
#        禁止springboot自动注入数据源配置。
#        为了后续利用注解动态传入的参数,对应连接相应数据库。为多数据源连接使用。
        exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure

服务成功启动!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值