美文网首页
四,Spring Boot基于MySQL,MyBatis配置Pa

四,Spring Boot基于MySQL,MyBatis配置Pa

作者: Wocus | 来源:发表于2018-09-25 15:21 被阅读17次
基于数据库连接的配置
1.在Gradle配置
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.2')
compile group: 'com.github.pagehelper', name: 'pagehelper-spring-boot-starter', version: '1.2.4'
2.在application.yml配置
## 该配置节点为独立的节点,有很多同学容易将这个配置放在spring的节点下,导致配置无法被识别
mybatis:
  mapper-locations: classpath:mybatis/mapper/*.xml  #注意:一定要对应mapper映射xml文件的所在路径
  type-aliases-package: com.wocus.demo1.model  # 注意:对应实体类的路径

#pagehelper分页插件
pagehelper:
    helperDialect: mysql
    reasonable: true
    supportMethodsArguments: true
    params: count=countSql

#打印SQL日志
logging:
  level:
     com.example.demo1.mapper : debug #前面的是包名

配置好执行的时候会发现找不到Mapper里面的类,需要去启动类配置一下,加上注释

@EnableAutoConfiguration(exclude= [DruidDataSourceAutoConfigure::class])
@MapperScan("com.example.demo1.mapper")

相关文章

网友评论

      本文标题:四,Spring Boot基于MySQL,MyBatis配置Pa

      本文链接:https://www.haomeiwen.com/subject/xglloftx.html