xml配置:
MP 其他配置
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
call-setters-on-nulls: true
object-wrapper-factory: com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory
配置bean
package com.zf.interact.conf;
import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;
import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
/**
* 配置mp 使用map查询返回驼峰命名
*/
@Component
@ConfigurationPropertiesBinding
public class ObjectWrapperFactoryConverter implements Converter<String,ObjectWrapperFactory> {
@Override
public ObjectWrapperFactory convert(String source) {
try {
return (ObjectWrapperFactory) Class.forName(source).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
}