第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

多模塊項目的Spring Cloud客戶端配置

多模塊項目的Spring Cloud客戶端配置

慕斯王 2023-03-17 10:14:56
雖然我已經(jīng)成功地使用 GIT 作為后端屬性回購設置了 spring cloud config 客戶端/服務器。但是,對于我的一個客戶端代碼,我有一個遵循模塊結(jié)構(gòu)(maven)的基本問題:客戶 1:  common (maven module)  app (maven module)  web (Contains the spring boot application, bootstrap.properties, application.properties)對于上述結(jié)構(gòu),我能夠從 spring cloud config 服務器讀取/刷新“web”模塊的屬性(因為那是我的 SpringBootApplication 所在的那個),但是無法理解如何在中注入配置/注入屬性其他模塊也一樣,比如公共模塊或應用程序模塊可能有屬性。我嘗試在其他模塊中添加 bootstrap.properties,它們指向同一個 spring 云配置服務器。但這沒有成功。Spring cloud config server application.properties:服務器.port=8888spring.cloud.config.server.git.uri=管理.security.enabled=falseWeb 模塊的 bootstrap.propertiesspring.application.name=測試spring.cloud.config.uri= http://localhost:8888管理.security.enabled=falsespring.profiles.active=默認,產(chǎn)品Maven 依賴項(云配置客戶端):    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-actuator</artifactId>        <version>1.4.4.RELEASE</version>    </dependency>    <dependency>        <groupId>org.springframework.cloud</groupId>        <artifactId>spring-cloud-starter-config</artifactId>        <version>1.1.2.RELEASE</version>    </dependency>    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-web</artifactId>        <version>1.4.4.RELEASE</version>    </dependency>請幫助我理解,關(guān)于如何讀取/刷新跨多個模塊(如將部署在單個實例/客戶端上的通用、應用程序或 Web)的屬性。
查看完整描述

1 回答

?
青春有我

TA貢獻1784條經(jīng)驗 獲得超8個贊

由于您的commonapp模塊不是應用程序,它們不會啟動,因此不會讀取您的 bootstrap.properties 文件。

查看類型安全配置屬性第三方配置。

您的commonapp模塊可以提供多個類及其屬性。在模塊的 Java 配置中,web您可以設置bootstrap.properties和/或application.properties文件中的值與配置類之間的綁定。由于@ConfigurationProperties注解,Spring Boot 將創(chuàng)建這些配置類的常規(guī) bean。這樣你就可以像任何其他 bean 一樣注入你的配置。

希望有幫助!:)


查看完整回答
反對 回復 2023-03-17
  • 1 回答
  • 0 關(guān)注
  • 178 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號