二、启动类加注解com.github.ulisesbocchio jasypt-spring-boot-starter1.16 org.jasypt jasypt1.9.2
@EnableEncryptableProperties //启动数据库加密功能三、打开cmd,执行命令根据规则,生成相应的加密字符
#用户名加密 java -cp F:wasumavenrepository-jcgorgjasyptjasypt1.9.2jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="root" password=test123 algorithm=PBEWithMD5AndDES #密码加密 java -cp F:wasumavenrepository-jcgorgjasyptjasypt1.9.2jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="123456" password=test123 algorithm=PBEWithMD5AndDES四 、配置文件中加配置
jasypt:
encryptor:
# 这里的password其实是加盐(加解密的salt值),可自定义
password: test123
spring:
application:
name: testservice
profiles:
active: prod
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/test_server?serverTimezone=Asia/Shanghai&autoReconnect=true&useUnicode=true&zeroDateTimeBehavior=convertToNull&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true
#username和password是根据规则生成的加密字符,填写在ENC()中即可
username: ENC(28PZpJtO4xxxxxxxx==)
password: ENC(5YpDMNwDevKxxxxxxsxgG+4y/U)



