问题描述
我曾经有一个tomcat
连接池配置,它限制了初始池的大小:spring.datasource.tomcat.initial-size=2
I used to have a tomcat
connection pool configuration restricting the initial pool size: spring.datasource.tomcat.initial-size=2
现在切换到hikaricp
:限制最初启动的连接的等效条件是什么?
Now switching to hikaricp
: what is the equivalent to restrict the initially started connections?
旁注:spring.datasource.hikari.minimumIdle
不会阻止在启动时初始化10个连接.
Sidenote: spring.datasource.hikari.minimumIdle
does not prevent initializing 10 connections at startup.
推荐答案
我刚刚发现它与我配置多个数据源有关.
I just found out it had to do with my configuration of multiple datasources.
通常,属性spring.datasource.hikari.minimum-idle=2
自动正确限制启动池的大小!
In general, the property spring.datasource.hikari.minimum-idle=2
automatically restricts the startup pool size correctly!
但是,如果有多个数据源,则缺少配置属性,如下所示:
But if having multiple data sources, there was a configuration property missing, as follows:
@Bean
@ConfigurationProperties("spring.datasource.secondary.hikari")
public DataSource secondatyDataSource() {
return ...
}
在我刚拥有"spring.datasource.secondary"
之前,并没有考虑到我的财产"spring.datasource.secondary.hikari.*"
.
Before I just had "spring.datasource.secondary"
, and there by my property "spring.datasource.secondary.hikari.*"
was not taken into account.
这可能是错误的记载 https://docs.spring. io/spring-boot/docs/current/reference/html/howto-data-access.html
This is probably wrong documented inhttps://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html
这篇关于如何在Hikaricp中限制初始池大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!