How to restrict initial pool size in hikaricp?

前端 未结 3 1349
离开以前
离开以前 2021-01-20 01:38

I used to have a tomcat connection pool configuration restricting the initial pool size: spring.datasource.tomcat.initial-size=2

Now switch

3条回答
  •  迷失自我
    2021-01-20 02:07

    I just found out it had to do with my configuration of multiple datasources.

    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 ...
        }
    

    Before I just had "spring.datasource.secondary", and there by my property "spring.datasource.secondary.hikari.*" was not taken into account.

    This is probably wrong documented in https://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html

提交回复
热议问题