Spring boot整合mybatis puls遇到的问题

1、启动报错


APPLICATION FAILED TO START


Description:

Field iCsDataVerifyService in com.lonelywolf.boot.linuxdatasource.mydemo.controller.CsDataVerifyController required a bean of type ‘com.lonelywolf.boot.linuxdatasource.mydemo.mapper.CsDataVerifyMapper’ that could not be found.

The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean of type ‘com.lonelywolf.boot.linuxdatasource.mydemo.mapper.CsDataVerifyMapper’ in your configuration.

找不到对应的文件:
a.在mapper文件中使用@mapper注解
b.或者在spring boot启动类中,使用@MapperScan(basePackages = {“com.lonelywolf.boot.linuxdatasource.mydemo.mapper”})
直接指定位置,也可以使用mapperScan注解效果是一样的

2、上面都弄好以后,启动时还可能出现以下问题
Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver’. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

java.sql.SQLException: The connection property ‘zeroDateTimeBehavior’ acceptable values are: ‘CONVERT_TO_NULL’, ‘EXCEPTION’ or ‘ROUND’. The value ‘convertToNull’ is not acceptable.
是因为jdbc驱动包版本过高,(这里依赖的是8.**的版本)
切换为5.**的版本以后,正常启动

3、mybatis-plus代码生成器,生成的xml文件位置是与java文件在一块,可以移动到resource下,也可以不移动,不移动需要在pom.xml中,指定xml文件放在java目录下

  </build>
  		<resources>
            <resource>
           		 <!-- xml放在java目录下-->
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
        </resources>
    </build>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值