mybatis-plus环境配置

前言:

开始做项目才发现写SQL是多么繁琐,只能搬出之前的mybatis-plus来,全称代码增删改查。

mybatis-plus简介:

Mybatis-Plus(简称MP)是一个 Mybatis 的增强工具,在 Mybatis 的基础上只做增强不做改变,为简化开发、提高效率而生。这是官方给的定义,关于mybatis-plus的更多介绍及特性,可以参考mybatis-plus官网。那么它是怎么增强的呢?其实就是它已经封装好了一些crud方法,我们不需要再写xml了,直接调用这些方法就行,就类似于JPA。

 

Springboot整合Mybatis-plus

1.pom.xml添加依赖



		com.baomidou
		mybatis-plus-boot-starter
		3.2.0

2.application.yml配置Mybatis-plus

#mybatis-plush配置
mybatis-plus:
  type-aliases-package: com.jd.pojo
  mapper-locations: classpath:/mybatis/mappers/*.xml
  configuration:
    map-underscore-to-camel-case: true
#配置控制台打印日志Debug,用来查看sql写没写错
logging:
  level: 
    com.jd.mapper: debug

 

type-aliases-package: com.jd.pojo是你实体类的路径

mapper-locations: classpath:/mybatis/mappers/*.xml是你mapper路径

 

还有别忘记配置数据库连接

jdbc
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql:///数据库名?useUnicode=true&characterEncoding=utf8
    username: root
    password: root

 

 

 

 

你可能感兴趣的:(环境配置)