【发布时间】:2020-10-23 14:23:34
【问题描述】:
我有一个 Spring Boot 项目,它在 application.yml 文件中将 Jasypt 用于 encrypting properties。
Jasypt 总是在使用解密密码的任何依赖项之前初始化和解密密码。
但是我现在也想使用Azure Key Vault。这个依赖现在tries to access its properties before they have been decrypted by Jasypt。
如何更改 Spring Boot 初始化这些依赖项的顺序? 对于这两个依赖项,我没有在应用程序中定义任何 @Bean。
我创建了一个Demo-Repository。
它是一个普通的 Spring Boot 项目。唯一改变的是:
在pom.xml 中添加了两个依赖项:
<!-- Azure Key Vault -->
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault-secrets-spring-boot-starter</artifactId>
<version>2.2.5</version>
</dependency>
<!-- Jasypt -->
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>2.1.2</version>
</dependency>
在application.yml:
jasypt:
encryptor:
password: test
azure:
keyvault:
enabled: true
uri: ENC(1pGS+OSU9a9Bs+2iAjhyVd8NonXkLp0BsPBOuUzcyJSFnABs+bc5jw==)
client-id: test
client-key: test
tenant-id: test
错误:
java.lang.IllegalArgumentException: The Azure Key Vault url is malformed.
(...)
Caused by: java.net.MalformedURLException: no protocol: ENC(1pGS+OSU9a9Bs+2iAjhyVd8NonXkLp0BsPBOuUzcyJSFnABs+bc5jw==)
如您所见,首先 Azure Key Vault 初始化自身,尝试使用 azure.keyvault.uri 但 Jasypt 尚未解密。
在这种情况下,我希望它尝试连接但由于 URL 不存在而无法连接。但它至少应该使用解密版本。
非常感谢任何建议。
【问题讨论】:
标签: java spring-boot maven dependencies azure-keyvault