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