spring43+mybatis345+mybatis-plus219 去掉自动驼峰设置在mybatis-configxml中添加如下配置来去掉自动驼峰设置:xmlconfiguration settings !-- 关闭自动驼峰命名转换 -- setting name=mapUnderscoreToCamelCase value=false settingsconfigurati
可能是配置文件没有正确加载或者被覆盖了。请检查以下几点:
-
确保mybatis-config.xml文件在classpath根目录下,且已被正确加载。可以在代码中打印Mybatis的configuration对象,查看是否包含了该配置。
-
如果是通过Spring配置Mybatis的话,可能需要将该配置添加到SqlSessionFactoryBean中。可以在Spring配置文件中添加如下配置:
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:mybatis-config.xml"/>
<property name="mapperLocations" value="classpath*:mapper/*.xml"/>
<property name="configuration">
<bean class="org.apache.ibatis.session.Configuration">
<property name="mapUnderscoreToCamelCase" value="false"/>
</bean>
</property>
</bean>
- 如果仍然无效,可以在Mapper接口上添加@MapUnderscoreToCamelCase(false)注解来禁用自动驼峰命名转换
原文地址: https://www.cveoy.top/t/topic/f6zW 著作权归作者所有。请勿转载和采集!