1、Spring Boot会默认加载DataSourceAutoConfiguration,就是数据库链接的配置项,如果你的项目没有用到数据库的话,在application.yml中就不会有数据库链接的配置项,运行的时候就会报错,这个问题弄了我一个上午,所以没有用到数据库,就必须在application加上@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}),这样Spring Boot就不会去加载数据库链接配置项了
2、Spring Boot + MyBatis + 通用Mapper(tk.mybatis.mapper-spring-boot-starter) + 分页插件Pagehelper(com.github.pagehelper.pagehelper-spring-boot-starter)踩的坑,因为com.github.pagehelper.pagehelper-spring-boot-starter中已经存在了很多的默认配置,而修改了dialect为com.github.pagehelper.dialect.helper.MySqlDialect后,就不能分页了
解决方案:
1、去掉dialect配置
2、将dialect改为helper-dialect
完整配置如下:
mybatis:
type-aliases-package: com.cache.demo.pojo
mapper:
mappers: com.cache.demo.base.BaseMapper
identity: MYSQL
pagehelper:
row-bounds-with-count: true
reasonable: true
support-methods-arguments: true
params: count=countSql
helper-dialect: com.github.pagehelper.dialect.helper.MySqlDialect