springboot 2.0 mariadb hikari-cp连接池

直到今天 2018年9月29日 10:00:38 ,hikari-cp 在maven 官方仓库最新版本为2.6

SpringBoot 2.0.5 控制台输出,默认的是 2.7.9

spring-boot-starter-jdbc\2.0..RELEASE\spring-boot-starter-jdbc-2.0..RELEASE.jar;H:\localRepository\com\zaxxer\HikariCP\2.7.\HikariCP-2.7..jar;

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>org.lzw</groupId>
<artifactId>hikaricp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>hikaricp</name>
<description>hikaricp for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency> <!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.3.0</version>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency> <!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency> <dependency>
<groupId>org.lzw</groupId>
<artifactId>jbatis</artifactId>
<version>1.0</version>
</dependency> <dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> </dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>

application.yml

spring:
datasource:
driver-class-name: org.mariadb.jdbc.Driver
url: jdbc:mysql://192.168.91.137:3306/sharding_test?serverTimezone=Hongkong&useUnicode=true&characterEncoding=UTF-8&useSSL=false
type: com.zaxxer.hikari.HikariDataSource
hikari:
# driver-class-name: org.mariadb.jdbc.Driver
# jdbc-url: jdbc:mysql://192.168.91.137:3306/sharding_test?serverTimezone=Hongkong&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root
password: root
minimum-idle: 5
maximum-pool-size: 50
auto-commit: true
idle-timeout: 30000
pool-name: HikariCpExample
max-lifetime: 1800000
connection-timeout: 30000
connection-test-query: SELECT 1 jpa:
show-sql: true
database-platform: org.hibernate.dialect.MariaDB103Dialect

单元测试

/**
* @author laizhenwei
* @date 2018/09/29
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class ShardingEntityServiceTest { @Resource
private ShardingEntityService shardingEntityService; @Test
public void addTests(){
shardingEntityService.save(new ShardingEntity().setOrgId(1L).setData("1"));
} }
上一篇:SQL Server 2008 远程过程调用失败[ VS2012]


下一篇:爬虫_网页url设计