SpringBoot 快速整合MyBatis

1、添加maven依赖注解

         
        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
            <scope>runtimescope>
        dependency>
        
        <dependency>
            <groupId>org.mybatis.spring.bootgroupId>
            <artifactId>mybatis-spring-boot-starterartifactId>
            <version>1.1.1version>
        dependency>

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语句于控制台




<configuration>

    <settings>
        
        <setting name="logImpl" value="STDOUT_LOGGING"/>
    settings>

configuration>

你可能感兴趣的:(SpringBoot)