From 43df7c4ff5e0ad52a45092bf7635ff8cc0d3cca8 Mon Sep 17 00:00:00 2001 From: jay <75509151@qq.com> Date: Mon, 7 Aug 2023 16:14:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20postgrep=E9=85=8D=E7=BD=AE=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 66 ++++++++++++++----- 1 file changed, 49 insertions(+), 17 deletions(-) diff --git a/iot-starter/src/main/resources/application.yml b/iot-starter/src/main/resources/application.yml index 4023ae7f..a4e3d10e 100644 --- a/iot-starter/src/main/resources/application.yml +++ b/iot-starter/src/main/resources/application.yml @@ -69,23 +69,55 @@ spring: #=======内置H2数据库连接设置结束==========>> +# <<==========mysql配置开始============== # <<==========mysql配置开始============== - # datasource: - # url: jdbc:mysql://127.0.0.1:3306/iotkit?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false - # driverClassName: com.mysql.cj.jdbc.Driver - # username: root - # password: 123456 - # validationQuery: SELECT 1 - # testOnBorrow: true - # jpa: - # database: MySQL - # database-platform: org.hibernate.dialect.MySQL5InnoDBDialect - ## show-sql: true - # hibernate: - # ddl-auto: update - # properties: - # hibernate: - # format_sql: true + datasource: + url: jdbc:postgresql://127.0.0.1:5432/iotkit + driverClassName: org.postgresql.Driver + username: postgres + password: 123456 + validationQuery: SELECT 1 + testOnBorrow: true + + type: com.zaxxer.hikari.HikariDataSource + # 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content + dynamic: + hikari: + connection-timeout: 5000 + idle-timeout: 30000 # 经过idle-timeout时间如果连接还处于空闲状态, 该连接会被回收 + min-idle: 5 # 池中维护的最小空闲连接数, 默认为 10 个 + max-pool-size: 16 # 池中最大连接数, 包括闲置和使用中的连接, 默认为 10 个 + max-lifetime: 60000 # 如果一个连接超过了时长,且没有被使用, 连接会被回收 + is-auto-commit: true + primary: master #设置默认的数据源或者数据源组,默认值即为master + strict: true #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源 + datasource: + # 主库数据源 + master: + type: ${spring.datasource.type} + driverClassName: org.postgresql.Driver + # jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562 + # rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题) + url: jdbc:postgresql://127.0.0.1:5432/iotkit + username: postgres + password: 123456 + # 从库数据源 + slave: + lazy: true + type: ${spring.datasource.type} + driverClassName: org.postgresql.Driver + url: jdbc:postgresql://127.0.0.1:5432/iotkit + username: postgres + password: 123456 + jpa: + database: MySQL + database-platform: org.hibernate.dialect.MySQL5InnoDBDialect + # show-sql: true + hibernate: + ddl-auto: update + properties: + hibernate: + format_sql: true # ============mysql配置结束============>> #<<================es时序数据配置开始=============== @@ -111,7 +143,7 @@ spring: redis: #使用内置redis的配置 #host: redis - host: 127.0.0.1 + host: 192.168.6.129 port: 6379 database: 0