(一)
mybatis-plus自带map下划线转驼峰配置类
我们只需要在yml中配置一下object-wrapper-factory指定MybatisMapWrapperFactory就可以了
mybatis-plus: mapper-locations: classpath:mapper/*Mapper.xml configuration: call-setters-on-nulls: true map-underscore-to-camel-case: true object-wrapper-factory: com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory
@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); } } }
(二)
@Bean public ConfigurationCustomizer mybatisConfigurationCustomizer(){ return configuration -> configuration.setObjectWrapperFactory(new MybatisMapWrapperFactory()); }
标签:map,MybatisMapWrapperFactory,plus,mybatis,configuration,public From: https://www.cnblogs.com/RedOrange/p/17091664.html