問題
如何將Azure AppConfiguration與SpringBoot 2.5.x或更高版本集成?
資訊
我試圖將Azure AppConfiguration資源用于Spring Boot 2.5.4專案。不幸的是,我無法讓它從 AppConfiguration 中讀取設定,甚至在我看來,無法連接到它。
該專案是通過
新創建的。
我不完全確定設定名稱的格式。我試圖根據這個檔案來建立格式。
配置類應該沒有問題,因為在mysampleservice中的注釋會導致使用訊息的值。
歡迎任何提示!
一些更多的資訊來闡述已接受的答案
。答案中鏈接的檔案指的是兩個不同的包。在maven資源庫中,一開始鏈接的是spring-cloud-azure-appconfiguration-config,而后面使用的是azure-spring-cloud-appconfiguration-config。第二種是與bootstrap.properties檔案一起作業的。
作業的pom.xml和bootstrap.properties:
...
<dependencies>/span>
<!--從azure應用程式配置資源加載配置的依賴。注意,在bootstrap.properties中需要額外的設定
設定的檔案:https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/appconfiguration/azure-spring-cloud-starter-appconfiguration-config
-->
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>azure-spring-cloud-appconfiguration-config-web</artifactId>
<version>/span>2.1.0</version>
</dependency>/span>
...
# Use this to enable or disable the cloud config, disabling it results in application.yaml beeeing.
spring.cloud.azure.appconfiguration.enabled=true
# Connection string to azure app configuration resource
spring.cloud.azure.appconfiguration.store[0].connection-string= Endpoint=https://myofficeconfiguration.azconfig.io;Id=zUcT-l9-s0:PFYfW7WM0/Pz7WZOnH3v;Secret=JTB9myJqGekDAJ5m8Z1vjmkJZrPd88JbOEE3EqoqJYs=
# 為之前定義的應用程式配置資源中的設定配置了過濾器。
spring.cloud.azure.appconfiguration.store[0].selects[0].key-filter = /mysampleservice/
spring.cloud.azure.appconfiguration.store[0].selects[0].label-filter= sample
spring.cloud.azure.appconfiguration.store[0].selects[1].key-filter = /notificationservice/。
spring.cloud.azure.appconfiguration. stores[0].selects[1].label-filter = Sample2
uj5u.com熱心網友回復:
bootstrap.yml/bootstrap.properties仍然可以使用,它們不再是基礎Spring包的一部分。
另外,你要在2.0.0和更高版本的https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/appconfiguration/azure-spring-cloud-starter-appconfiguration-config中使用這個檔案。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/324174.html
標籤:
上一篇:VBA-查找最后一列
