问题描述

今天在搭建springboot + mybatis 环境的时候service中方法返回值为空。在网上查找方法,大多数都是说controller里引用service没有加@Autowired注解。但我是加了的。
springboot + mybatis 搭载环境service返回结果为空的解决办法
24、25行都有输出说明我的service是没问题的也是能从页面拿到结果的唯独26行输出为空,我猜想可能是数据库没查到数据
springboot + mybatis 搭载环境service返回结果为空的解决办法
于是在配置文件中加入打印sql配置
springboot + mybatis 搭载环境service返回结果为空的解决办法
重启查看日志
springboot + mybatis 搭载环境service返回结果为空的解决办法
可以看到我的数据库是可以查到数据的,那么问题出现在哪里呢?
难道是数据库和实体类的映射出问题了,好像有道理。查看之后,果然是这个问题。

我的实体类属性名为:
springboot + mybatis 搭载环境service返回结果为空的解决办法
数据库字段为:
springboot + mybatis 搭载环境service返回结果为空的解决办法

查询语句为:

springboot + mybatis 搭载环境service返回结果为空的解决办法
真相因该大白了吧,我用的是 *

于是:
springboot + mybatis 搭载环境service返回结果为空的解决办法
然后返回值正常
springboot + mybatis 搭载环境service返回结果为空的解决办法

相关文章:

  • 2022-12-23
  • 2022-01-03
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
  • 2021-08-04
  • 2021-04-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
  • 2021-06-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案