0
点赞
收藏
分享

微信扫一扫

Mybatis/Mybatis-Plus驼峰式命名映射

Python芸芸 2022-02-05 阅读 58

方法一:

在springboot配置文件application.yml中写入配置信息如下:

mybatis-plus:
configuration:
#在映射实体或者属性时,将数据库中表名和字段名中的下划线去掉,按照驼峰命名法映射 address_book ---> addressBook
map-underscore-to-camel-case: true

方法二:

通过mybatis配置文件:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>
<settings>
<!-- 开启驼峰,开启后,只要数据库字段和对象属性名字母相同,无论中间加多少下划线都可以识别 -->
<setting name="mapUnderscoreToCamelCase" value="true" />
</settings>
</configuration>
举报

相关推荐

0 条评论