mybatis结果封装到hashmap中没有null的数据

1、在ssm框架中

在mybatis-config.xml配置文件中加下面这句代码即可解决 

<setting name="callSettersOnNulls" value="true"/>  

2、在springboot中

mybatis:
  type-aliases-package: com.hoohui.houtai.model
  mapper-locations: classpath:mapper/*.xml
#mybatis解决返回为HashMap或者LinkedHashMap时,某些结果集的字段null,导致map中少key的问题
  configuration:
    call-setters-on-nulls: true

 

posted @ 2019-07-12 16:02  DHR~小白  阅读(758)  评论(0编辑  收藏  举报