[英]Jasypt not able to decrypt password from system environment variable with Spring
我有 jasypt 密碼和 application.yml 中定義的加密密碼,如下所示:
jasypt:
encryptor:
password: ${secretKey}
spring:
datasource:
password: ENC(${password})
並為它使用@Value:
@Value("${spring.datasource.password}")
private String springPassword;
我已經在我的環境變量中定義了 secretKey 和密碼。 但是當我啟動這個 Spring Boot 應用程序時,它拋出錯誤:
Caused by: org.springframework.cache.Cache$ValueRetrievalException: Value for key 'spring.datasource.password' could not be loaded using 'com.ulisesbocchio.jasyptspringboot.caching.CachingDelegateEncryptablePropertySource$$Lambda$209/172678484@5ae15'
如果我對兩個鍵進行硬編碼,則它工作正常。
任何幫助,將不勝感激。
我有類似的問題。 就我而言,原因是我在類路徑上有 jasypt-1.9.2.jar 和 jasypt-1.9.4.jar。
jasypt-1.9.4.jar 來自 jasypt-spring-boot 2.1.1 的依賴。 jasypt-1.9.2.jar 來自 wss4j-ws-security-common 2.2.2 的依賴。
更改為 jasypt-spring-boot 2.1.0 解決了我的問題。
我知道為時已晚,但仍然如此。 對我來說,將 ENC() 方法作為環境變量的一部分起作用。
jasypt:
encryptor:
password: ${secretKey}
spring:
datasource:
password: ${PASSWORD}
設置環境變量時
export PASSWORD=ENC(yourPassword)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.