【问题标题】:Hikari configuration for Mysql using spring boot使用 Spring Boot 的 Mysql 的 Hikari 配置
【发布时间】:2019-04-17 10:10:46
【问题描述】:

我有使用 MySQL 数据库的 spring boot 应用程序。我正在使用 hikari 连接池。

根据 Hikari https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration 的官方博客,我必须设置一些属性以提高性能,例如

dataSource.prepStmtCacheSize=250
dataSource.prepStmtCacheSqlLimit=2048
dataSource.useServerPrepStmts=true
dataSource.useLocalSessionState=true

但我不确定如何在不显式创建 HikariDataSource bean 的情况下设置这些属性,如此链接中所述:https://github.com/brettwooldridge/HikariCP/issues/1200

我渴望通过spring配置文件(属性文件或YML文件)直接设置这些属性

【问题讨论】:

标签: mysql spring-boot configuration hikaricp


【解决方案1】:

这些参数可以通过简单的配置轻松配置。

只需将这些属性/属性附加到标准 spring 数据源中 -> url 属性

spring.datasource.url=jdbc:mysql://localhost:3306/databasename?rewriteBatchedStatements=true&useLocalSessionState=true&cachePrepStmts=true&prepStmtCacheSize=250&prepStmtCacheSqlLimit=2048

类似地,其他属性也可以使用 & 符号附加。

【讨论】:

    猜你喜欢
    • 2019-10-28
    • 2019-02-03
    • 2022-09-29
    • 1970-01-01
    • 1970-01-01
    • 2018-10-05
    • 2020-05-17
    • 2019-07-31
    • 2021-12-16
    相关资源
    最近更新 更多