栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java > SpringBoot

spring boot-2.0.x + mybatis

SpringBoot 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

spring boot-2.0.x + mybatis

搭建项目

选择java版本和项目类型

添加项目依赖

这三个貌似没有用,删掉

pom.xml

    4.0.0

    com.littlebear
    shop
    0.0.1-SNAPSHOT
    jar

    shop
    Demo project for Spring Boot

    
        org.springframework.boot
        spring-boot-starter-parent
        2.0.3.RELEASE
         
    

    
        UTF-8
        UTF-8
        1.8
    

    
        
            org.springframework.boot
            spring-boot-starter-web
        
        
            org.mybatis.spring.boot
            mybatis-spring-boot-starter
            1.3.2
        

        
            mysql
            mysql-connector-java
            runtime
        
        
            org.springframework.boot
            spring-boot-starter-test
            test
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    
添加以下依赖
        
        
            com.github.pagehelper
            pagehelper-spring-boot-starter
            1.2.5
        

        
        
            com.alibaba
            druid-spring-boot-starter
            1.1.9
        
项目结构

image.png

项目启动类加上包扫描

image.png

配置文件,改成yml格式,把application.properties后缀改成yml即可
spring:
  datasource:
    name: shop    type: com.alibaba.druid.pool.DruidDataSource    #druid相关配置
    druid:      #监控统计拦截的filters
      filters: stat
      driver-class-name: com.mysql.jdbc.Driver      #基本属性
      url: jdbc:mysql://127.0.0.1:3306/shop?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&userSSL=false
      username: root
      password: root      #配置初始化大小/最小/最大
      initial-size: 1
      min-idle: 1
      max-active: 20      #获取连接等待超时时间
      max-wait: 60000      #间隔多久进行一次检测,检测需要关闭的空闲连接
      time-between-eviction-runs-millis: 60000      #一个连接在池中最小生存的时间
      min-evictable-idle-time-millis: 300000
      validation-query: SELECT 'x'
      test-while-idle: true
      test-on-borrow: false
      test-on-return: false
      #打开PSCache,并指定每个连接上PSCache的大小。oracle设为true,mysql设为false。分库分表较多推荐设置为false
      pool-prepared-statements: false
      max-pool-prepared-statement-per-connection-size: 20

mybatis:
  mapper-locations: classpath:mybatis/mapper/*Mapper.xml  type-aliases-package: com.littlebear.model#pagehelperpagehelper:
    helperDialect: mysql
    reasonable: true
    supportMethodsArguments: true
    params: count=countSql
    returnPageInfo: check



作者:hllcve_
链接:https://www.jianshu.com/p/6d1ec357470b


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/235829.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号