Reason: Failed to determine a suitable driver class

Reason: Failed to determine a suitable driver class

错误描述

今天基于SpringBoot2.0集成Dubbo,并按分模块的方式划分出了服务提供者和服务消费者,服务提供者工程中包含jdbc连接及提供源数据功能,服务消费者主要通过RPC来远程调用服务提供者的服务。
项目启动过程中,服务提供者可以正常启动,且可以正常访问数据库。服务消费者出现以下的问题:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2m2018-09-15 17:16:04.227[0;39m [31mERROR[0;39m [35m43824[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.b.d.LoggingFailureAnalysisReporter  [0;39m [2m:[0;39m 
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
    If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
    If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

错误分析

该问题是由于在消费者项目中引入了mybatis-spring-boot-starter的依赖,这个依赖会根据自动配置约束自己去配置数据源,而消费者项目中并没有dataSource相关的配置,所以出错。

解决方案

  1. 在消费者工程中移除mybatis-spring-boot-starter依赖
  2. 在消费者工程启动时,排除数据源自动配置即可,在SpringBootApplication注解时增加exclude= {DataSourceAutoConfiguration.class}属性,即:
    @SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
  • 7
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值