mybatis3.2以上版本都会出现:

返回map value为空字段不显示(mybatis默认:call-setters-on-nulls=false)

五种方法:

1.在application.yml添加:

mybatis:
  configuration:
    call-setters-on-nulls: true

2.在application.properties添加:

#当查询数据为空时字段返回为null,不加这个查询数据为空时,字段将被隐***ybatis.configuration.call-setters-on-nulls=true

3.在mybatis.xml添加:

<configuration>

<settings>

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

</settings>

</configuration>

4.在sql里面设置(空值赋空):

IFNULL(test, '') AS test

5.在数据源配置文件中,添加默认配置,如下所示:

//设置默认属性
org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
configuration.setCallSettersOnNulls(true);
sf.setConfiguration(configuration);