We have summarized how to set up a connection pool with Spring Boot (Spring Data JPA).
The connection pool libraries are selected in the following order. (Check if there is a library in the classpath, select that library if it exists, and check the next library if not.)
If you are using spring-boot-starter-jdbc
or spring-boot-starter-data-jpa
, HikariCP will be resolved as a dependency, so if nothing is set, HikariCP will be selected. To.
It can be changed by specifying the DataSource (javax.sql.DataSource
inheritance class) of the library you want to use in the spring.datasource.type
property of ʻapplication.properties (or ʻapplications.yaml
).
See Configuration for the items that can be set.
spring:
datasource:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost/test_db
username: user
password: password
type: com.zaxxer.hikari.HikariDataSource
hikari:
maximum-pool-size: 20
minimum-idle: 10
See Common Attributes for the items that can be set.
spring:
datasource:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost/test_db
username: user
password: password
type: org.apache.tomcat.jdbc.pool.DataSource
tomcat:
max-active: 20
min-idle: 10
Recommended Posts