SpringBoot中的Mybatis依赖问题(springboot整合mybatis依赖)

网友投稿 338 2022-08-02


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

补充:下面再看下spring boot集成mybatis需要的相关依赖

junit

junit

test

org.springframework.boot

spring-boot-starter-aop

spring-boot-starter-amqp

spring-boot-starter-web

http://

spring-boot-starter-test

spring-boot-starter-actuator

     

     

org.mybatis.spring.boot

spring-boot-starter

     

spring-boot-starter-jdbc

     

spring-boot-starter-security

     

spring-boot-starter-redis

mybatis-spring-boot-starter

1.1.1

mysql

mysql-connector-java

com.alibaba

fastjson

1.2.30

druid

1.0.24

org.hibernate

hibernate-validator

5.3.1.Final

javax.servlet

javax.servlet-api

3.0.1

provided

commons-httpclient

commons-httpclient

3.1

com.github.pagehelper

pagehelper

4.1.6


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Java实现文本编译器(java语言的编译器)
下一篇:java实现登录窗口(java用户登陆界面)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~