【发布时间】:2023-01-12 00:21:40
【问题描述】:
我正在尝试设置 Spring Boot 应用程序以连接到 Azure keyvault 并获取机密。 我查看了各种代码示例,但无法让其中一个正常工作。
没有与 keyvault 库本身相关的错误,但是 Spring bean 没有使用从 secret 中获取的属性进行初始化。
我使用的是 Spring boot 2.7.3,keyvault starter lib 是 4.2.0。这就是我提到的获取我的属性配置。 https://microsoft.github.io/spring-cloud-azure/4.2.0/reference/html/appendix.html#_azure_key_vault_secrets_properties
application.yml
------------
spring:
cloud:
azure:
keyvault:
secret:
enabled: true
endpoint: https://uri/
credential:
client-certificate-path: <path to pem file>
client-id: <client-id>
profile:
tenant-id: <tenant-id>
build.gradle
--------------
implementation 'com.azure.spring:spring-cloud-azure-starter-keyvault-secrets:4.2.0'
Spring bean
-------------
@Configuration
@Getter
@Setter
public class AKVProperties {
@Value("${MYAPP-DB-LOGIN-PASSWORD}")
private String dbPassword1;
...
Exception at startup:
----------------------
Error creating bean with name 'AKVProperties': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'MYAPP-DB-LOGIN-PASSWORD' in value "${MYAPP-DB-LOGIN-PASSWORD}"
【问题讨论】:
标签: spring-boot azure-keyvault