springbootl利用druid型数据库密码加密

springboot druid数据库密码加密

1 引入依赖(下载jar包)

       

            com.alibaba

            druid-spring-boot-starter

            1.1.14

       

2、生成加密密码(两种方法)

(2-1) java -cp D:\mavenCk\.m2\\com\alibaba\druid\1.1.14\druid-1.1.14.jar  com.alibaba.druid.filter.config.ConfigTools 123456

说明: 红色部分为jar所在位置,123456为密码

(2-2) 使用druid 中的方法直接的到密文()

springbootl利用druid型数据库密码加密_第1张图片

 

3、结果

(私钥:忽略)

privateKey:MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEAhTTMh0Pp5/uGoux1dFxK6FazUsdoaM6SknZI3bTSE16XN4ad1iCIp/ER6Zj6eRzARpk9OpDfSUf8+yDwSVTrPwIDAQABAkBXRme3PGT1zJPDDYBLM+kUXzHwy5v6B1Z7RaqqMD3v1++gZf0LwWfXbzyMKpYQEXBPBnqGwb7nw/m4hxgts3MBAiEA82fSsAm7CDmfx2QgeEAbAcqRavL6wGGaVGT50GNcxr8CIQCMGUN9atISNRmsFhIrpr1Jabd7G85kPs6T14hakKl7gQIgLmYzPoWMVsQNVkga/HFT9KJ12ApbjILOlZnuGTBnxicCIA/iFVq0r5hM2No/rlOwlakrCRg18NJApJ7yQo0x9WUBAiAwUlM3BDaHagZIBswp3/IWoxKts13ZIPfous+k8NC+7w==

(公钥-配置文件用到的key)

publicKey:MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIU0zIdD6ef7hqLsdXRcSuhWs1LHaGjOkpJ2SN200hNelzeGndYgiKfxEemY+nkcwEaZPTqQ30lH/Psg8ElU6z8CAwEAAQ==

(密文密码)

password:cICX+15JRaq92TFEDl1h+qj9on9Nvoxhn2pJX0xRb1apN0QK+pHoBNnbvUf8NgBLU94qPf4lfFul+9cYAPb0MQ==

 

5、springboot配置文件

server.port=81

server.connection-timeout=30000

file.path=D:/upload/wen/

spring.datasource.type=com.alibaba.druid.pool.DruidDataSource

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/caidingnu?characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2b8

spring.datasource.username=root

spring.datasource.password=cICX+15JRaq92TFEDl1h+qj9on9Nvoxhn2pJX0xRb1apN0QK+pHoBNnbvUf8NgBLU94qPf4lfFul+9cYAPb0MQ==

spring.datasource.druid.connect-properties.config.decrypt=true

spring.datasource.druid.connect-properties.config.decrypt.key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIU0zIdD6ef7hqLsdXRcSuhWs1LHaGjOkpJ2SN200hNelzeGndYgiKfxEemY+nkcwEaZPTqQ30lH/Psg8ElU6z8CAwEAAQ==







mybatis-plus.configuration.map-underscore-to-camel-case=true

mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl

mybatis-plus.configuration.call-setters-on-nulls=true

# 初始连接数

spring.datasource.druid.initialSize=5

# 最小连接池数量

spring.datasource.druid.minIdle=10

# 最大连接池数量

spring.datasource.druid.maxActive=20

# 配置获取连接等待超时的时间

spring.datasource.druid.maxWait=60000

# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒

spring.datasource.druid.timeBetweenEvictionRunsMillis=60000

# 配置一个连接在池中最小生存的时间,单位是毫秒

spring.datasource.druid.minEvictableIdleTimeMillis=300000

# 配置一个连接在池中最大生存的时间,单位是毫秒

spring.datasource.druid.maxEvictableIdleTimeMillis=900000

# 配置检测连接是否有效

spring.datasource.druid.validationQuery=SELECT 1 FROM DUAL

spring.datasource.druid.testWhileIdle=true

spring.datasource.druid.testOnBorrow=false

spring.datasource.druid.testOnReturn=false

spring.datasource.druid.web-stat-filter.enabled=true

spring.datasource.druid.stat-view-servlet.enabled=true

# 设置白名单,不填则允许所有访问

spring.datasource.druid.stat-view-servlet.allow=

spring.datasource.druid.stat-view-servlet.url-pattern=/monitor/druid/*

spring.datasource.druid.filter.stat.enabled=true

# 慢SQL记录

spring.datasource.druid.filter.stat.log-slow-sql=true

spring.datasource.druid.filter.stat.slow-sql-millis=1000

spring.datasource.druid.filter.stat.merge-sql=true

spring.datasource.druid.filter.wall.config.multi-statement-allow=true

#数据库过滤器

spring.datasource.druid.filter.config.enabled=true

 

 

 

你可能感兴趣的:(druid)