springboot与mybatis整合各种报错

启动项目报错

错误1:

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

Description:

Field faceCustomerMapper in com.example.demo.service.impl.FaceServiceImpl required a bean of type 'com.example.demo.mapper.FaceCustomerMapper' 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.example.demo.mapper.FaceCustomerMapper' in your configuration.

报错大意找不到mapper文件

解决办法:在启动类里面加上MapperScan注解,括号里面的注解写自己的

@MapperScan("com.example.demo.mapper")

 

同样的如果controller和service扫描不到的话也加@ComponentScan 这个注解就好了。

 

错误2:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.demo.mapper.FaceCustomerMapper.selectByPrimaryKey 

原因1:xml中的namespace路径要写对

原因2 application.yml 配置文件的mybatis配置要加,而且不能写错

如果一开始相对路径不行的话,一定要用绝对路径试一下。

注意一下 我 的XML文件是放在配置文件下面的

 

错误3:启动都正常搞一个测试类测试发现还报错

java.sql.SQLNonTransientConnectionException: Cannot load connection class because of underlying exception: com.mysql.cj.exceptions.WrongArgumentException: Malformed database URL, failed to parse the connection string near ';autoReconnectForPools=true&noAccessToProcedureBodies=true&useunicode=true&zeroDateTimeBehavior=convertToNull'.

这种就是数据库链接不对 修改一下就好了 用&拼接,去掉amp;

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值