Use gradle on SpringBoot 1.5.3 introduced hikariCP

Use gradle on SpringBoot 1.5.3 introduced hikariCP

hikari from the Japanese term, "light" means, known as "the fastest in the history database connection pool", also springboot2.0 latest version of the default connection pool. But springboot1.5.x project can also be used.

springboot1.5.x default database connection pool is tomcat-jdbc connection pool, you want to migrate to modify hikari connection pool only a few steps to configure on:

build.gradle file

1, first remove the default tomcat connnection pool from dependence

 compile("org.springframework.boot:spring-boot-starter-data-jpa:1.5.3.RELEASE"){
              exclude group: 'org.apache.tomcat', module: 'tomcat-jdbc'
    }

2, dependent on the introduction of

compile group: 'com.zaxxer', name: 'HikariCP', version: '3.4.1'

 

3, application.properties connection pool configuration file properties

spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.pool-name=SomeThingHikariCP
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.idle-timeout=600000
spring.datasource.hikari.maximum-pool-size=20
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.connection-timeout=6000
spring.datasource.hikari.connection-test-query=SELECT 1 FROM DUAL

The original spring.datasource.tomcat.xxxx need commented out.

Restart the project, the console will see the following log

...

com.zaxxer.hikari.HikariDataSource [110] - AppUserHikariCP - Starting...
com.zaxxer.hikari.pool.PoolBase [527] - AppUserHikariCP - Driver does not support get/set network timeout for connections. (com.mysql.jdbc.JDBC4Connection.getNetworkTimeout()I)
com.zaxxer.hikari.HikariDataSource [123] - AppUserHikariCP - Start completed.

...

Description database connection pool successful migration.

Guess you like

Origin www.cnblogs.com/lyhero11/p/12097593.html