美文网首页
springboot配置数据库密码加密

springboot配置数据库密码加密

作者: 少年眼蓝不及海 | 来源:发表于2020-08-03 17:59 被阅读0次

1.导入依赖

<!-- 加密依赖 -->

<dependency>

<groupId>com.github.ulisesbocchio</groupId>

    <artifactId>jasypt-spring-boot-starter</artifactId>

    <version>3.0.2</version>

</dependency>

2.找到jasypt-1.9.3.jar所在位置,如图打开输入cmd,然后Enter

java -cp jasypt-1.9.3.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="你要加密的字符串" password=你要加的盐 algorithm=PBEWithMD5AndDES


4.在application.properties文件中配置

//之前的盐

jasypt.encryptor.password=salt

//ENC(加密的密文)

spring.datasource.username="ENC(sBdk7fXxdnCZMzPjGkZr0g==)"

spring.datasource.password="ENC(sBdk7fXxdnCZMzPjGkZr0g==)"

5.在Application.class配置注解

//配置数据库加密注解

@EnableEncryptableProperties

相关文章

网友评论

      本文标题:springboot配置数据库密码加密

      本文链接:https://www.haomeiwen.com/subject/vudbrktx.html