问题描述
我想在没有任何连接池的情况下使用Spring Boot 2.1应用程序(在本例中为HikariCP),因为默认池是HikariCP!
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 ?
用例是我想为我的所有应用程序
实例和其他应用程序使用一个通用的数据库缓冲池(pgBouncer)!
当每个Spring Boot应用程序使用其自己的隐式连接池(HikariCP)运行时,我无法实现。
The use case is I want to use a common db pooler (pgBouncer) for all my applicationinstances 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 ?
推荐答案
您还可以通过提供简单的驱动程序数据源来停用它:
You can also deactivate it by providing simple driver datasource:
public DataSource datasource() throws SQLException {
Driver driver = DriverManager.getDriver(url);
SimpleDriverDataSource dataSource = new SimpleDriverDataSource(driver, url, username, password);
return dataSource;
}
这篇关于没有HikariCP连接池的Spring Boot 2.1 App的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!