已解决:
如题,
1.当使用spring boot加mybatis时,设置Map返回,当值为空时属性也会没有
在application.properties中加入下面配置,将会解决这个问题。
#当查询数据为空时字段返回为null,不加这个查询数据为空时,字段将被隐藏
mybatis.configuration.call-setters-on-nulls=true
2.与springBoot搭配使用时:把下面configuration这段复制到yml中就行了
mybatis:
mapperLocations: classpath*:mapper/**/*.xml
#mybatis数据库字段内容为空时,返回该字段
configuration:
call-setters-on-nulls: true
3.mybatis配置中修改:
<settings>
<setting name="cacheEnabled" value="true"/>
<setting name="callSettersOnNulls" value="true"/>
</settings>