gpt4 book ai didi

java - Spring Boot 2.x 中 HikariCP 默认有连接池吗?

转载 作者:行者123 更新时间:2023-11-30 01:46:07 25 4
gpt4 key购买 nike

我正在使用 Spring Framework (spring boot 2.1.5) 开发一个 Web 服务,它必须生成一个连接池(没有 JNDI)。

我听说Spring Data(当spring boot的版本高于2.X时)实现了HikaryCP来管理连接,但我确实知道这是自动发生的还是我必须激活通过一些配置。

如果是这样,则每个使用 Spring Data 且 Spring Boot 版本高于 2.x 的服务默认都有一个始终激活且工作的连接池。这是真的吗?

如果这是真的,有人有任何引用书目可以让我阅读HikariCP的默认属性吗?

--------------------------------已添加------------- -------------

我在一本书中找到了以下信息:

https://books.google.com/books?id=au1mDwAAQBAJ&pg=PA40&dq=spring+boot+and+HikariCP&hl=en&sa=X&ved=2ahUKEwjmh4aY68vkAhUWrp4KHTbKCq4Q6AEwAXoECAEQAg#v=onepage&q=spring%20boot%20and%20HikariCP&f=false

在 Spring Boot 2.0 中,默认的基本 DataSoruce 初始化仅针对嵌入式数据库启用,一旦使用生产数据库就会禁用。配置属性spring.datasource.initialization-mode(值始终或从不),它取代了旧的spring.datasource.initialize配置属性,可供用户进行更多控制.

最佳答案

光是 on by default在 Spring boot 2+ 中

If we are using Spring Boot 2.0 and onwards, Spring Boot selects HikariDataSource by default

github 中的所有 hikari 属性有完整解释

maximumPoolSize This property controls the maximum size that the pool is allowed to reach, including both idle and in-use connections. Basically this value will determine the maximum number of actual connections to the database backend. A reasonable value for this is best determined by your execution environment. When the pool reaches this size, and no idle connections are available, calls to getConnection() will block for up to connectionTimeout milliseconds before timing out. Please read about pool sizing. Default: 10

关于java - Spring Boot 2.x 中 HikariCP 默认有连接池吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57911982/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com