步骤一:先生成加密的密码:
步骤二:配置application.yaml文件:
spring:datasource:driver-class-name: com.mysql.cj.jdbc.Drivertype: com.alibaba.druid.pool.DruidDataSourcedruid:username: rootpassword: aPJ35s+aFz6ASmnmNtW2F8ttxru9mNCuX0upxY8N4dpT/vY//4rDRpClt784GtP5wXm2tRUQgbMNudQryvCR+A==url: jdbc:mysql://xx.xx.xxx.xxx:3306/cityinfo?useUnicode=true&characterEncoding=utf8&serverTimezone=UTCinitial-size: 5min-idle: 5max-active: 20max-wait: 60000time-between-eviction-runs-millis: 60000min-evictable-idle-time-millis: 300000validation-query: SELECT 1 FROM DUALtest-while-idle: truetest-on-borrow: falsetest-on-return: falsepool-prepared-statements: false#配置监控统计拦截的filters,stat:监控统计、log4j:⽇志记录、wall:防御sql注入#如果允许时报错 java.lang.ClassNotFoundException: org.apache.log4j.Priority#则导入 log4j 依赖即可,Maven 地址:https://mvnrepository.com/artifact/log4j/log4jfilters: 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: truedruid.stat.slowSqlMillis: 5000config.decrypt: trueconfig.decrypt.key: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJAg7cxPhDRczpTuqjnHgZlfztB4gwCxso+Ysz+Ohw4tshdDLmP9ziTj3DEyWkBbsR3Dte4X10xa6oh1nvZkyj0CAwEAAQ==
# config.decrypt.key: ${your_public_key}