How to restrict initial pool size in hikaricp?

membersound :

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

Now switching to hikaricp: what is the equivalent to restrict the initially started connections?

Sidenote: spring.datasource.hikari.minimumIdle does not prevent initializing 10 connections at startup.

membersound :

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=85883&siteId=1