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配置注解
//配置數(shù)據庫加密注解
@EnableEncryptableProperties