1、mybatis整合spring

(1)pom.xml

  1. <dependency>
  2. <groupId>mysql</groupId>
  3. <artifactId>mysql-connector-java</artifactId>
  4. </dependency>
  5. <dependency>
  6. <groupId>org.mybatis.spring.boot</groupId>
  7. <artifactId>mybatis-spring-boot-starter</artifactId>
  8. <version>1.3.0</version>
  9. </dependency>

(2)application.properties

  1. # DataSourceProperties
  2. spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
  3. spring.datasource.url=jdbc:mysql://localhost:3306/community?characterEncoding=utf-8&sueSSL=false&serverTimezone=GMT%2B8
  4. spring.datasource.username=root
  5. spring.datasource.password=123456
  6. spring.datasource.type=com.zaxxer.hikari.HikariDataSource
  7. #最大连接数
  8. spring.datasource.hikari.maximum-pool-size=15
  9. #最小空闲连接
  10. spring.datasource.hikari.minimum-idle=5
  11. #超时时间30000毫秒
  12. spring.datasource.hikari.idle-timeout=30000
  13. #MybatisProperties
  14. mybatis.mapper-locations=classpath:mapper/*.xml
  15. mybatis.type-aliases-package=com.guang.community.entity
  16. #自动生成组件
  17. mybatis.configuration.use-generated-keys=true
  18. #create_time与createTime的转换
  19. mybatis.configuration.map-underscore-to-camel-case=true

2、将日志级别设置为debug便于调试