Created
January 9, 2023 03:32
-
-
Save laxman1129/ea2adaff0f31e4a4c7c7f32fb666e433 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| To switch from Atomikos to Hikari connection pooling in a Spring Boot application, you will need to do the following: | |
| Exclude the Atomikos dependency from your project: | |
| <dependency> | |
| <groupId>org.springframework.boot</groupId> | |
| <artifactId>spring-boot-starter-jta-atomikos</artifactId> | |
| <exclusions> | |
| <exclusion> | |
| <groupId>com.atomikos</groupId> | |
| <artifactId>transactions-jta</artifactId> | |
| </exclusion> | |
| <exclusion> | |
| <groupId>com.atomikos</groupId> | |
| <artifactId>transactions-jdbc</artifactId> | |
| </exclusion> | |
| </exclusions> | |
| </dependency> | |
| Add the Hikari dependency to your project: | |
| <dependency> | |
| <groupId>com.zaxxer</groupId> | |
| <artifactId>HikariCP</artifactId> | |
| <version>3.4.5</version> | |
| </dependency> | |
| Configure the DataSource bean in your Spring configuration class: | |
| @Bean | |
| @ConfigurationProperties(prefix = "spring.datasource.hikari") | |
| public DataSource dataSource() { | |
| return DataSourceBuilder.create().type(HikariDataSource.class).build(); | |
| } | |
| Add the Hikari configuration properties to your application.properties or application.yml file: | |
| spring: | |
| datasource: | |
| type: com.zaxxer.hikari.HikariDataSource | |
| validation-query: SELECT 1 FROM DUAL | |
| min-idle: ${DS_MIN_IDLE:5} | |
| max-idle: ${DS_MAX_IDLE:15} | |
| max-active: ${DS_MAX_ACTIVE:20} | |
| initial-size: ${DS_INIT_SIZE:5} | |
| test-on-borrow: true | |
| test-on-return: true | |
| test-while-idle: true | |
| time-between-eviction-runs-millis: ${DS_EVIC_TIMEOUT:5000} | |
| hikari: | |
| jdbc-url: ${DB_URL:jdbc:oracle:thin:} | |
| username: ${DB_USERNAME:} | |
| password: ${DB_PASSWORD:} | |
| driver-class-name: oracle.jdbc.driver.OracleDriver | |
| idle-timeout: ${HIK_IDLE_TIMEOUT:60000} | |
| minimum-idle: ${HIK_MIN_IDLE:5} | |
| maximum-pool-size: ${HIK_MAX_POOL_SIZE:20} | |
| connection-timeout: ${HIK_CON_TIMEOUT:30000} | |
| leak-detection-threshold: 60000 | |
| This should configure your Spring Boot application to use the Hikari connection pool. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment