使用 spring 引导的 Mysql 的 Hikari 配置
Hikari configuration for Mysql using spring boot
我有 spring 个使用 MySQL 数据库的启动应用程序。我正在使用 hikari 连接池。
根据 Hikari https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration 的官方博客,我必须设置一些属性来提高性能,例如
dataSource.prepStmtCacheSize=250
dataSource.prepStmtCacheSqlLimit=2048
dataSource.useServerPrepStmts=true
dataSource.useLocalSessionState=true
但我不确定如何在不显式创建 HikariDataSource bean 的情况下设置这些属性,如 link 中所述:https://github.com/brettwooldridge/HikariCP/issues/1200
我希望通过 spring 配置文件(属性 文件或 YML 文件)直接设置这些属性
这些参数可以通过简单的配置轻松配置。
只需在标准 spring 数据源中附加这些 property/properties -> url 属性
spring.datasource.url=jdbc:mysql://localhost:3306/databasename?rewriteBatchedStatements=true&useLocalSessionState=true&cachePrepStmts=true&prepStmtCacheSize=250&prepStmtCacheSqlLimit=2048
类似地,可以使用&符号附加其他属性。
我有 spring 个使用 MySQL 数据库的启动应用程序。我正在使用 hikari 连接池。
根据 Hikari https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration 的官方博客,我必须设置一些属性来提高性能,例如
dataSource.prepStmtCacheSize=250
dataSource.prepStmtCacheSqlLimit=2048
dataSource.useServerPrepStmts=true
dataSource.useLocalSessionState=true
但我不确定如何在不显式创建 HikariDataSource bean 的情况下设置这些属性,如 link 中所述:https://github.com/brettwooldridge/HikariCP/issues/1200
我希望通过 spring 配置文件(属性 文件或 YML 文件)直接设置这些属性
这些参数可以通过简单的配置轻松配置。
只需在标准 spring 数据源中附加这些 property/properties -> url 属性
spring.datasource.url=jdbc:mysql://localhost:3306/databasename?rewriteBatchedStatements=true&useLocalSessionState=true&cachePrepStmts=true&prepStmtCacheSize=250&prepStmtCacheSqlLimit=2048
类似地,可以使用&符号附加其他属性。