在pom.xml中添加依赖
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>2.1.1</version>
</dependency>
在config中添加类
package cc.admin.config;
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.springframework.context.annotation.Configuration;
/**
* @description: 配置文件属性加解密配置类
*/
@Configuration
@EnableEncryptableProperties
public class JasyptConfig {
}
在yml中写秘钥
message:
access-id: ENC(wedsdcvwewefwewewewe==)
secret-sec: ENC(qw12fswezfwefwefwe==)
jasypt:
encryptor:
password: 123sdqwwqwd