SpringBoot 多模組 配置覆蓋問題

2021-09-05 10:01:21 字數 682 閱讀 4853

因為現在手上有個專案,在未拆分成微服務之前,會有多個層級的模組依賴,如下圖:

現在有個問題,我在common裡面配置了乙個屬性值叫做:project.mark=123, 在 biz module1 中需要它的值是 456,在ui-module1中需要這個值是789.

這種情況,可以配置profile 或者 properties+yml檔案來實現。

properties+yml:

profile:

your configuration bean.class上面定義的configurationproperties("***")中的***這個值進行覆蓋。

例子:

SpringBoot 多環境配置

在我們的實際開發中,一般都有三套環境,開發環境,測試環境,生產環境,三套環境的資料庫連線配置也有所不同,比如,埠,ip位址等等。如果在打包時候都頻繁的修改配置檔案資訊,那必將是非常容易出錯的地方。還有乙個正式 在這個檔案中配置 spring.profiles.active test來指明對應哪個檔案...

springboot多環境配置

dev本地開發環境 server.port 1111 test測試環境 server.port 2222 pre預發布環境 server.port 3333 proc生產環境 server.port 4444 dev本地開發環境 spring.profiles.active dev test測試環境...

SpringBoot配置Profile多環境支援

1 多profile檔案定義形式 2 多profile文件塊形式 server port 8080 spring profiles prod server port 8081 spring profiles test server port 8082 spring profiles dev複製 1 ...