Mybatis-plus配置下划线转驼峰
yml+Java代码
mybatis-plus:
mapper-locations: classpath*:/mybatis/*.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.example.demo.model
configuration:
#开启下划线转驼峰
map-underscore-to-camel-case: true
#开启返回map结果集的下划线转驼峰
object-wrapper-factory: com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory
直接配置类
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
import com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @Author felix fei
* @Date 2021/1/28 0028 16:00
* @Version 1.0.1
* @describe: mybatis配置类
*/
@Configuration
public class MybatisPlusConfig {
/**
* 下划线转驼峰
*
* @return
*/
@Bean
public ConfigurationCustomizer mybatisConfigurationCustomizer() {
return new ConfigurationCustomizer() {
@Override
public void customize(
org.apache.ibatis.session.Configuration configuration) {
configuration.setObjectWrapperFactory(new MybatisMapWrapperFactory());
}
};
}
}
网友评论