简体   繁体   English

更改由Spring Boot项目生成的与数据库的连接数

[英]Change number of connection to database generated by a spring boot project

I have generated a spring boot project using jHipster. 我已经使用jHipster生成了一个Spring Boot项目。 I want to reduce the number of connections to the database so I have modified the application-prod.yml file by adding the maximumPoolSize tag like this 我想减少与数据库的连接数,因此我通过添加maximumPoolSize标记修改了application-prod.yml文件

datasource:
    type: com.zaxxer.hikari.HikariDataSource
    url: jdbc:mysql://localhost:3306/db?useUnicode=true&characterEncoding=utf8&useSSL=false
    username: root
    password:
    maximumPoolSize: 2

But when I try deploying the application I have 10 connections to the database. 但是,当我尝试部署应用程序时,我与数据库有10个连接。 What am I doing wrong? 我究竟做错了什么?

Thanks 谢谢

With Spring Boot 1.4 the general properties have been reduced and moved to specific properties per DataSource provider (which is also explained in the reference guide and the release notes ). 使用Spring Boot 1.4,常规属性已被减少,并已移至每个DataSource提供程序的特定属性(在参考指南发行说明中也有介绍)。

So instead of using spring.datasource.maximumPoolSize you should be using spring.datasource.hikari.maximumPoolSize 因此,而不是使用spring.datasource.maximumPoolSize你应该使用spring.datasource.hikari.maximumPoolSize

For a list of properties see the appendix . 有关属性的列表,请参见附录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM