搭建项目
选择java版本和项目类型
添加项目依赖
这三个貌似没有用,删掉
pom.xml添加以下依赖4.0.0 com.littlebear shop0.0.1-SNAPSHOT jar shop Demo project for Spring Boot org.springframework.boot spring-boot-starter-parent2.0.3.RELEASE UTF-8 UTF-8 1.8 org.springframework.boot spring-boot-starter-weborg.mybatis.spring.boot mybatis-spring-boot-starter1.3.2 mysql mysql-connector-javaruntime org.springframework.boot spring-boot-starter-testtest org.springframework.boot spring-boot-maven-plugin
项目结构com.github.pagehelper pagehelper-spring-boot-starter1.2.5 com.alibaba druid-spring-boot-starter1.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



