Spring Boot 1.5.3创建的连接超出application.properties

时间:2019-02-25 12:10:52

标签: postgresql hibernate spring-boot spring-data-jpa

我正在一个配置了双重数据源的项目中。在测试中,我将最大活动连接数限制为五个,但是当我检查数据库时,发现该应用程序创建了大约25个以上的连接。

代码示例

# Number of ms to wait before throwing an exception if no connection is available.
spring.datasource.tomcat.max-wait=1000
# Maximum number of active connections that can be allocated from this pool at the same time.
spring.datasource.tomcat.max-active=1
spring.datasource.tomcat.max-idle=1
spring.datasource.tomcat.min-idle=1
spring.datasource.tomcat.initial-size=1
# Validate the connection before borrowing it from the pool.
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.test-while-idle = true
spring.datasource.tomcat.validation-query = true
spring.datasource.tomcat.time-between-eviction-runs-millis = 360000


spring.rdatasource.tomcat.max-wait=1000
# Maximum number of active connections that can be allocated from this pool at the same time.
spring.rdatasource.tomcat.max-active=1
spring.rdatasource.tomcat.max-idle=1
spring.rdatasource.tomcat.min-idle=1
spring.rdatasource.tomcat.initial-size=1
# Validate the connection before borrowing it from the pool.
spring.rdatasource.tomcat.test-on-borrow=true
spring.rdatasource.tomcat.test-while-idle= true
spring.rdatasource.tomcat.validation-query = true
spring.rdatasource.tomcat.time-between-eviction-runs-millis = 360000

以上连接工作正常,但没有超过与数据库的连接数。我正在使用的用户限于10个连接。

当我遇到对应用程序的请求而不是得到 查询等待超时错误,无法创建初始池大小。

我正在使用tomcat连接池

请向我提供解决方案,以便应用程序可以在数据库中设置的10个连接限制下运行。

0 个答案:

没有答案