问题
I want to use my Spring Boot 2.1 App without any connection pooler (HikariCP in this case) since the default pooler is HikariCP !
How should I go ahead and implement this ?
The use case is I want to use a common db pooler (pgBouncer) for all my application instances and other applications ! I cannot achieve this when each Spring Boot app runs with its own implicit connection pooler(HikariCP).
How should I implement this use case ? Is this a better solution for common database connection pooling ?
回答1:
You can exclude HikariCP through the POM.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<artifactId>com.zaxxer</artifactId>
<groupId>HikariCP</groupId>
</exclusion>
</exclusions>
</dependency>
Then you can create your own JdbcTemplate
using whichever datasource you want. For more information on that, see here Creating custom connection pool in Spring Boot application
来源:https://stackoverflow.com/questions/55161884/spring-boot-2-1-app-without-hikaricp-connection-pooler