Spring datasource hikari
时间: 2023-09-07 10:17:44 浏览: 107
HikariCP is a high-performance JDBC connection pool for Java applications that provides maximum performance and stability. It is the default connection pool for Spring Boot applications. To use HikariCP as the datasource in a Spring application, you need to add the following dependencies to your project:
```
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</dependency>
```
Then, you can configure the datasource as follows:
```
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.url=jdbc:mysql://localhost/mydb
spring.datasource.username=myuser
spring.datasource.password=mypassword
```
This will configure HikariCP as the datasource for your Spring application. You can also customize the HikariCP configuration by adding additional properties to the configuration, such as connection pool size, connection timeout, and idle timeout.
阅读全文