最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
SpringBoot中的Mybatis依赖问题代码示例
时间:2022-06-29 01:48:37 编辑:袖梨 来源:一聚教程网
本篇文章小编给大家分享一下SpringBoot中的Mybatis依赖问题代码示例,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。
Pom导入依赖
org.mybatis.spring.boot mybatis-spring-boot-starter 2.0.0
application.yml
#配置数据源,yml格式 spring: datasource: url: jdbc:mysql://127.0.0.1:3306/dianping?useUnicode=true&characterEncoding=utf8 username: root password: 123 driver-class-name: com.mysql.jdbc.Driver #指定mybatis映射文件的地址 mybatis: mapper-locations: classpath:mapper/*.xml
项目结构
mybatis默认是属性名和数据库字段名一一对应的,即
数据库表列:user_name
实体类属性:user_name
但是java中一般使用驼峰命名
数据库表列:user_name
实体类属性:userName
在Springboot中,可以通过设置map-underscore-to-camel-case属性为true来开启驼峰功能。
application.properties中:
mybatis: configuration: map-underscore-to-camel-case: true
相关文章
- 原神奈芙尔值不值得抽-6.1奈芙尔抽取建议 10-17
- 三国望神州孙权阵容怎么搭配 孙权阵容搭配推荐 10-17
- 三国望神州道具怎么获得 道具获取攻略 10-17
- 零度曙光天赋点怎么获得 天赋点获取攻略 10-17
- 零度曙光冰晶剑怎么获得 冰晶剑获取攻略 10-17
- 零度曙光双刀怎么玩 双刀玩法教学 10-17