Spring Boot 配置文件密码加密方法
参考:https://github.com/ulisesbocchio/jasypt-spring-boot1、引入jasypt的jar包:<!-- https://mvnrepository.com/artifact/com.github.ulisesbocchio/jasypt-spring-boot --><dependency><groupId>com.
·
参考:https://github.com/ulisesbocchio/jasypt-spring-boot
Spring Boot 配置文件密码加密两种方案 - ken007 - 博客园
1、引入jasypt的jar包:
<!-- https://mvnrepository.com/artifact/com.github.ulisesbocchio/jasypt-spring-boot -->
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot</artifactId>
<version>2.1.0</version>
</dependency>
java -cp jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="123456" password=mego algorithm=PBEWithMD5AndDES
-
input的值就是原密码。这里特别注意:字符串一定要用双引号,用单引号就不行。
-
password的值就是参数jasypt.encryptor.password指定的值(即秘钥)。
2. 在Appliction文件中添加注解
@EnableEncryptableProperties
3.在application.properties中配置连接数据库的信息
注意:
加密字段需要用ENC(密文)的形式,直接写spring.datasource.username=y3laVKqTJamKS7KkUSaWRA==是无效的。
微信扫一扫:关注我个人订阅号“猿小飞”,更多精彩文章在这里及时发布:
更多推荐
已为社区贡献3条内容
所有评论(0)