springboot+MyBatis返回Map时值为null的字段会丢失
多数据源中,在的数据源配置里加上以下代码:
public SqlSessionFactory firstSqlSessionFactory(@Qualifier("firstDataSource") DataSource datasource)
throws Exception {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(datasource);
//------------------------------------------------加入的代码开始------------------------------------------------
org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
configuration.setCallSettersOnNulls(true);
bean.setConfiguration(configuration);
//------------------------------------------------加入的代码结束------------------------------------------------
bean.setMapperLocations(
// 设置mybatis的xml所在位置
new PathMatchingResourcePatternResolver().getResources("classpath*:mapper/first/*.xml"));
return bean.getObject();
}