SpringBoot中加密包对配置文件中的密码进行加密

来源:互联网 发布:spss时间序列数据预测 编辑:程序博客网 时间:2024/06/04 23:48

1.pom.xml

<!--java加密包对配置文件中的密码进行加密--><dependency>    <groupId>com.github.ulisesbocchio</groupId>    <artifactId>jasypt-spring-boot-starter</artifactId>    <version>1.8</version></dependency>

2.application.properties

jasypt.encryptor.password=123456

3.controller

@Autowiredprivate StringEncryptor stringEncryptor;
@RequestMapping("/testEnc")@ResponseBodypublic String encryptPwd() {    String result = stringEncryptor.encrypt("123456");    return result;}

4.最后将返回的result手动放到password

spring.datasource.password=ENC(u+xLqTbeOVm7MGhc45LEIw==)

阅读全文
0 0
原创粉丝点击