druid 1.2.14,application.yaml配置文件中,如何进行数据库加密配置

步骤一:先生成加密的密码:
在这里插入图片描述
步骤二:配置application.yaml文件:

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    type: com.alibaba.druid.pool.DruidDataSource
    druid:
      username: root
      password: aPJ35s+aFz6ASmnmNtW2F8ttxru9mNCuX0upxY8N4dpT/vY//4rDRpClt784GtP5wXm2tRUQgbMNudQryvCR+A==
      url: jdbc:mysql://xx.xx.xxx.xxx:3306/cityinfo?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC
      initial-size: 5
      min-idle: 5
      max-active: 20
      max-wait: 60000
      time-between-eviction-runs-millis: 60000
      min-evictable-idle-time-millis: 300000
      validation-query: SELECT 1 FROM DUAL
      test-while-idle: true
      test-on-borrow: false
      test-on-return: false
      pool-prepared-statements: false
      #配置监控统计拦截的filters,stat:监控统计、log4j:⽇志记录、wall:防御sql注入
      #如果允许时报错 java.lang.ClassNotFoundException: org.apache.log4j.Priority
      #则导入 log4j 依赖即可,Maven 地址:https://mvnrepository.com/artifact/log4j/log4j
      filters: stat,wall,log4j,config
      #指定每个连接上PSCache的大小
      max-pool-prepared-statement-per-connection-size: 20
      #合并多个DruidDataSource的监控数据,多数据源做主从时使用
      use-global-data-source-stat: true
      #通过connectProperties属性来打开mergeSql功能;慢SQL记录
      connect-properties:
        druid.stat.logSlowSql: true
        druid.stat.slowSqlMillis: 5000
        config.decrypt: true
        config.decrypt.key: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJAg7cxPhDRczpTuqjnHgZlfztB4gwCxso+Ysz+Ohw4tshdDLmP9ziTj3DEyWkBbsR3Dte4X10xa6oh1nvZkyj0CAwEAAQ==
#        config.decrypt.key: ${your_public_key}
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值