Springboot使用Mybatis启动时异常:Failed to determine a suitable driver class

今天复制已有Springboot工程用来新项目开发时,一直报下列错误:

***************************
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).

于是开始填坑之路: 

1、确认spring.datasource是否配置正常:

  • MySQL数据库服务已启动
  • 新建Springboot项目,复制之前项目的application.yml配置文件,运行正常
  • 可判断spring.datasource配置正确

2、确认Mybatis xml里包名和mapper接口包名是否一致----也没有问题

3、确认是不是application.yml配置文件文件没有被扫描

      痛苦了好久,突然想到,是不是application.yml配置文件文件没有被扫描?于是看在pom文件,发现问题:

 之前项目配置文件时application.properties,这次自己脑残,改成yml格式,导致文件没有被扫描到。。

<resources>
    <resource>
        <directory>src/main/java</directory>
        <includes>
            <include>**/*.properties</include>
            <include>**/*.xml</include>
        </includes>
        <filtering>false</filtering>
    </resource>
    <resource>
        <directory>src/main/resources</directory>
        <includes>
            <include>**/*.properties</include>
            <include>**/*.xml</include>
        </includes>
        <filtering>false</filtering>
    </resource>
</resources>

好脑残的一个坑,填好之后想着愉快的run一下,一切正常,发起一个请求,居然又报错:

org.apache.ibatis.binding.BindingException:Invalid bound statement (not found): XXX.XXX.XXMapper.get

唉,继续填坑!

我用的IDE是idea,我的xml文件都在resource目录下,包名和mapper接口包名一致(没有使用在application.yml配置),按道理maven install后会将xml和class放到target的同一目录下,但结果却是:

路径确实一致,却并没有把xml和class放到同一文件夹中!!于是悲催的把resource下目录删掉,重新创建了一遍,运行,测试!

OK!


其实问题很low,只作为自己填坑的一次记录,也希望能给大家一些帮助!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值