Spring Boot azure keyvault 按需刷新
我将 spring boot 与 azure 的 keyvault 一起使用,
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>azure-spring-boot-starter-keyvault-secrets</artifactId>
</dependency>
但是当我想更新密钥时出现问题。 例如,如何通过rest api强制刷新该值?
@Value("${x-value}") private val xValue: String = "0"
谢谢!
I am using spring boot with azure's keyvault
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>azure-spring-boot-starter-keyvault-secrets</artifactId>
</dependency>
but there is a problem, when I want to update secret.
How to force for example via rest api lets say, refresh of this value ?
@Value("${x-value}") private val xValue: String = "0"
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您能否重新表述您的问题以澄清您到底想要刷新什么?如果您想刷新 AKV 中的值(AKV 秘密更改 -> 代码更改中的值),您需要使用环境来获取属性:
因为 @Value() 是在组件构建期间设置的。它在其一生中不会改变。
如果您想要更改 AKV 内容:这不是 azure-spring-boot-starter-keyvault-secrets 的目的。
Can you rephrase you're question to clarify what exactly do you want to refresh? If you want to refresh the value from AKV (AKV secret changes -> value in code changes) you need to use environment to get the property:
because @Value() is set during construction of the component. It won't change during it's lifetime.
If you want the change the AKV contents: this is not the purpose of azure-spring-boot-starter-keyvault-secrets.