【问题标题】:jasypt encryption not working in spring bootjasypt 加密在 Spring Boot 中不起作用
【发布时间】:2018-05-16 08:16:46
【问题描述】:

我想对spring boot应用的application.properties文件中的一些敏感数据做加密。

为此我使用了 jasypt-spring-boot-starter 插件。

在 spring 应用程序中也使用了@EnableEncryptableProperties 标签。

我为我的数据库加密了访问密钥,并将其加密值写入了属性文件。

com.test.SharedAccessKey=ENC(vfQQ9veC1G+RV8BC0VA==)

也在属性文件中提供

jasypt.encryptor.password=secretpassword
jasypt.encryptor.algorithm=PBEWithMD5AndDES

我在 Spring Boot 应用程序中访问此属性如下

@Value("${com.test.SharedAccessKey}")
public String shareAcessKey;

但 logger.info(shareAcessKey) 打印为 ENC(vfQQ9veC1G+RV8BC0VA==)

我在上面缺少什么,谁能帮忙。

【问题讨论】:

  • 你的 pom 中有哪些 jasypt 依赖项以及你的 springboot 版本是什么
  • com.github.ulisesbocchiojasypt-spring-boot-starter2.0.0
  • org.springframework.bootspring-boot-starter-parent2.0.1.RELEASE

标签: spring spring-boot jasypt


【解决方案1】:

问题已解决。我在我的spring Configuration 类@Configuration 中做了一些与属性文件相关的配置。

设置属性占位符配置为 setIgnoreUnresolvablePlaceholders

删除上述代码后。 Jasypt 密码被取走。

【讨论】:

  • 你能举个例子吗?
  • 你能补充一下你所做的吗,因为我想通过参数传递这个 -Djasypt.encryptor.password=password 但它不能正常工作你能帮我如何传递这个
  • 请在您的解决方案中提供更多详细信息,以帮助其他关注此问题的人。
猜你喜欢
  • 2021-12-02
  • 1970-01-01
  • 1970-01-01
  • 2020-03-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-24
相关资源
最近更新 更多