• 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-jdbc2.0.5.RELEASEspring-boot-starter-jdbc-2.0.5.RELEASE.jar;H:localRepositorycomzaxxerHikariCP2.7.9HikariCP-2.7.9.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"));
        }
    
    }
  • 相关阅读:
    greta一些简单实用的字符串匹配
    内存管理
    粒子系统
    资源的后台加载
    GRETA正则表达式模板类库
    便利的开发工具log4cpp快速使用指南
    vc/mfc/vs2005下正则表达式源代码编程/微软greta Regular Expressions
    GRETA库在VS 2005环境下的编译经验
    揭开正则表达式的神秘面纱
    greta简单使用
  • 原文地址:https://www.cnblogs.com/sweetchildomine/p/9722165.html
Copyright © 2020-2023  润新知