在spring.xml中添加com.baomidou.mybatisplus.entity.GlobalConfiguration,需要先定义一个bean来初始化GlobalConfiguration,例如:

<bean id="globalConfig" class="com.baomidou.mybatisplus.entity.GlobalConfiguration">
    <property name="dbColumnUnderline" value="true"/>
</bean>

这里设置dbColumnUnderline为true,表示开启下划线转驼峰功能。然后在定义mybatis-plus的SqlSessionFactory时,将该bean注入进去:

<bean id="sqlSessionFactory" class="com.baomidou.mybatisplus.spring.MybatisSqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="globalConfig" ref="globalConfig"/>
</bean>

这样就可以去掉自动驼峰设置了,并且可以自定义GlobalConfiguration的其他属性

spring43+mybatis345+mybatis-plus219 去掉自动驼峰设置在springxml 如何添加combaomidoumybatisplusentityGlobalConfiguration

原文地址: https://www.cveoy.top/t/topic/f6Bf 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录