springboot整合mybatis非常非常的简单,简直简单到发指。但是也有一些坑,这里我会详细的指出会遇到什么问题,并且这些配置的作用

 

整合mybatis,无疑需要mapper文件,实体类,dao层,数据库连接池。。。。。也就没了。

先放配置application.yml

spring:
    datasource:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        filters: stat
        maxActive: 20
        initialSize: 1
        maxWait: 60000
        minIdle: 1
        timeBetweenEvictionRunsMillis: 60000
        minEvictableIdleTimeMillis: 300000
        validationQuery: select 'x'
        testWhileIdle: true
        testOnBorrow: false
        testOnReturn: false
        poolPreparedStatements: true
        maxOpenPreparedStatements: 20
        
        name: test
        url: jdbc:mysql://localhost:3306/mama-bike?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
        username: root
        password: root

mybatis:
  #告诉spring你的mapper的位置。
  mapper-locations: classpath:com/coder520/mamabike/**/**.xml
  #告诉spring你的实体类的位置
  type-aliases-package: classpath:com.coder520.mamabike.**.entity

logging:
  config: classpath:logback.xml
View Code

相关文章: