说明
HiKariCP是数据库连接池的一个后起之秀,号称性能最好,可以完美地PK掉其他连接池。
性能比较图:
官方github-> https://github.com/brettwooldridge/HikariCP,本文将HiKariCP应用到Springboot项目中,使用Springboot2.0.4.RELEASE+MySQL5+Mybatis进行数据库查询
快速开始
首先给出项目结构图:
初始化数据库的SQL:
CREATE DATABASE `persontest` CHARACTER SET 'utf8';
use persontest;
CREATE TABLE `persontest`.`userinfo` (
`id` int(0) NOT NULL,
`username` varchar(255) NULL,
PRIMARY KEY (`id`)
);
INSERT INTO userinfo(id,username) VALUES(0,'CSDN yunlingfly');
INSERT INTO userinfo(id,username) VALUES(1,'dakl');
INSERT INTO userinfo(id,username) VALUES(2,'dhasjk');
使用IDEA新建Springboot项目,更新pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.yunlingfly</groupId>
<artifactId>hikaricp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>hikaricp</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from re