zoukankan      html  css  js  c++  java
  • springboot druid连接池配置

    druid连接池的参数,基本上没有问题,这个参数配置经过1秒,10000个请求的插入测试,正常,如果管理系统类型的话,完全够用了

    server:
    port: 8083

    spring:
    datasource:
    driver-class-name: com.mysql.jdbc.Driver
    username: root
    password: root
    url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false
    druid:
    # 数据库类型
    db-type: com.alibaba.druid.pool.DruidDataSource
    initialSize: 5 # 初始化时建立连接的个数
    minIdle: 5 # 最小链接池数量
    maxActive: 20 # 最大连接池数量(缺省值:8)
    maxWait: 60000 # 获取连接时最大等待时间,单位毫秒
    timeBetweenEvictionRunsMillis: 60000 # 多久进行一次检测,检测需要关闭的空闲连接
    minEvictableIdleTimeMillis: 300000 # 配置一个连接在池中最小生存的时间,单位是毫秒
    # 是否缓存preparedStatement,也就是PSCache。PSCache对支持游标的数据库性能提升巨大,比如说oracle。在mysql下建议关闭。(缺省值:false)
    # pool-prepared-statements: false
    # 要启用PSCache,必须配置大于0,当大于0时,poolPreparedStatements自动触发修改为true。在Druid中,不会存在Oracle下PSCache占用内存过多的问题,可以把这个数值配置大一些,比如说100
    # max-open-prepared-statements: -1
    # 用来检测连接是否有效的sql,要求是一个查询语句。如果validationQuery为null,testOnBorrow、testOnReturn、testWhileIdle都不会起作用。
    validationQuery: select 'x'
    # 检测连接是否有效,配合validationQuery使用,这样配置性能更好
    testOnBorrow: false
    testOnReturn: false
    testWhileIdle: true
    # 插件: 监控统计用的filter:stat,防御sql注入的filter:wall
    filter:
    # 监控统计
    stat:
    # 数据库类型
    db-type: mysql
    # 慢SQL
    log-slow-sql: true
    # 慢SQL执行时间
    slow-sql-millis: 2000
    # 将同类的SQL合并 例如 select * from table where id = ? ; 如果不配置这个,则不带参数的查询,在druid页面会展示多个
    merge-sql: true
    wall:
    # 开启防止SQL注入
    enabled: true
    db-type: mysql
    # 配置对增删改查的限制,这里不做配置

    config:

    delete-allow: false

    drop-table-allow: false

    insert-allow: false

    mybatis:
    type-aliases-package: com.example.demo.entity
    mapper-locations: classpath:mapper/*Mapper.xml
    logging:
    config: classpath:log4j2_fu.xml

  • 相关阅读:
    Netty ChannelHandler组件作用
    Netty Channel组件作用
    Netty NioEventLoop自定义任务处理
    NIO与BIO
    JDK ByteBuffer与Netty ByteBuf
    linux-源码软件管理-yum配置
    typora使用快捷键
    远程连接mysql库问题
    MVC 后台处理 json格式的日期
    使用 SqlClient 创建数据库连接并获取数据
  • 原文地址:https://www.cnblogs.com/duende99/p/13581003.html
Copyright © 2011-2022 走看看