0
点赞
收藏
分享

微信扫一扫

SpringBoot Hikari数据源的正确配置是这样的

半秋L 05-26 13:00 阅读 1

SpringBoot Hikari数据源的正确配置是这样的

spring-boot version: spring-boot-starter:2.6.7

1. MySQL数据源配置

# 数据源配置
spring:
  datasource:
    type: com.zaxxer.hikari.HikariDataSource
    url: jdbc:mysql://localhost:3306/db_name
    username: my_user
    password: my_password
    driver-class-name: com.mysql.cj.jdbc.Driver
    hikari:
      connection-test-query: SELECT 1
      maximum-pool-size: 10

2. H2数据源配置

# 数据源配置
spring:
  datasource:
    type: com.zaxxer.hikari.HikariDataSource
    url: jdbc:h2:mem:db_name;DB_CLOSE_DELAY=-1;MODE=MYSQL
    username: sa
    password: 
    driver-class-name: org.h2.Driver
    hikari:
      connection-test-query: SELECT 1
      maximum-pool-size: 10
  h2:
    console:
      path: /h2
      enabled: true
      settings:
        trace: true
        web-allow-others: true
  sql:
    init:
      platform: h2
      schema-locations: classpath*:sql/init/schema/schema-{platform}.sql
      data-locations: classpath*:sql/init/data/data-{platform}.sql
举报

相关推荐

0 条评论