我正在设置一个Spring Boot应用程序以从hashicorp库中检索值 我的设置-
HC揭开了秘密-
vault kv put secret/custom/env/platform/ticket-service username="hotel-user"
Spring应用-Bootstrap.properties
spring.application.name=ticket-service
spring.cloud.vault.token=${VAULT_TOKEN}
spring.cloud.vault.scheme=http
spring.cloud.vault.uri=${VAULT_HOST_HTTPS}
spring.cloud.vault.host=${VAULT_HOST}
spring.cloud.vault.authentication=TOKEN
spring.cloud.vault.generic.enabled=false
spring.cloud.vault.kv.enabled=false
我的应用程序属性-
app.user=${user}
主类-
@VaultPropertySource(value = "secret/data/custom/env/platform/ticket-service")
public class TicketServiceApplication {
@Value("${app.user}")
private String username;
}
当我运行应用程序时,日志显示弹簧正在对所需路径上的Vault进行调用并返回结果。
"{"request_id":"XXXXXXXX","lease_id":"","renewable":false,"lease_duration":0,"data":{"data":{"username":"hotel-user"},"metadata":{"created_time":"XXX","deletion_time":"","destroyed":false,"version":8}},"wrap_info":null,"warnings":null,"auth":null}[\n]"
[restartedMain] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 200 OK
但是我希望库将值注入给定变量中,但不是。
文档说明了使用VaultTemplate的方法(并且可以使用),但是有没有办法将注入委派给spring,而不是编写自定义配置代码?