springboot+druid密码加密
1、在cmd控制台运⾏以下命令
jar下载:
java -cp druid-1.1.21.jar com.alibaba.fig.ConfigTools root  //root 就是你要加密的密码
执⾏结果:
C:\administrator\Program Files\Thunder Network\gv>java -cp druid-1.1.21.jar com.alibaba.fig.ConfigTools root
privateKey:MIIBVgIBADANBgkqhkiG9w0BAQEFAASCAUAwggE8AgEAAkEAq8QAe5w6oE8xL/aHJLm+8EQjuL8ok1ACdwDKygDOMP3MtPTkRRhNxIz+vLomp5UHAjYHAuB7/E9Ghc7tM1/IHQIDAQ publicKey:MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKvEAHucOqBPMS/2hyS5vvBEI7i/KJNQAncAysoAzjD9zLT05EUYTcSM/ry6JqeVBwI2BwLge/xPRoXO7TNfyB0CAwEAAQ== password:krh9x0zn/ESXIgZPrMxBpyMef1bZ1t/vbwE9EcqdY0qTSi4iK3vnJfbyiWu7mT2A/uhx1MDnKzE3C1YT0Ry2lg==
2、配置application.properties
#mysql驱动
spring.datasource.sql.cj.jdbc.Driver
#连接数据库url
spring.datasource.url=jdbc:mysql://localhost:3306/mybatisplus?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8
#⽤户名
spring.datasource.username=root
# 启⽤ConfigFilter
spring.datasource.abled=true
# 配置 connection-properties,启⽤加密,配置公钥。
public-key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKvEAHucOqBPMS/2hyS5vvBEI7i/KJNQAncAysoAzjD9zLT05EUYTcSM/ry6JqeVBwI2BwLge/xPRoXO7TNfyB0CAwEAAQ==
#加密并注⼊publicKey
spring.tion-properties=config.decrypt=true;config.decrypt.key=${public-key}
#密码
spring.datasource.password=krh9x0zn/ESXIgZPrMxBpyMef1bZ1t/vbwE9EcqdY0qTSi4iK3vnJfbyiWu7mT2A/uhx1MDnKzE3C1YT0Ry2lg==
#连接池druid阿⾥巴巴
wispring是什么意思
pe=com.alibaba.druid.pool.DruidDataSource
3、JAR包引⼊
<!-- mvnrepository/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.21</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
4、官⽹详细:
到此结束,就是这么简单!

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。