Spring Boot 2.1 App without HikariCP Connection pooler

柔情痞子 提交于 2019-12-24 21:16:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!