SpringBoot 快速整合MyBatis

1、添加maven依赖注解

         
        
            mysql
            mysql-connector-java
            runtime
        
        
        
            org.mybatis.spring.boot
            mybatis-spring-boot-starter
            1.1.1
        

2、配置application.yml

spring:
  profiles:
    active: pro
# 数据库链接
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8
    username: root
    password: 
    dbcp:
      max-idle: 8
      min-idle: 8
      initial-size: 10
      max-active: 20

#mybatis 配置
mybatis:
  type-aliases-package: com.xx.model
  mapper-locations: classpath:mybatis/mapper/*.xml
  configLocation: classpath:mybatis/mybatis-config.xml

3、配置mybatis-config.xml输出sql语句于控制台






    
        
        
    


你可能感兴趣的:(SpringBoot 快速整合MyBatis)