原文:SpringBoot中獲取spring.profiles.active的值

一 網上很多采用 Profile dev 的方式獲取,但是這個是類級別的 二 開發中可能需要代碼級別 剛開始我想通過classpath下的文件讀取方式,麻煩死了,於是換了個思路。 SpringBoot啟動日志中有下面這句: : : . restartedMain INFO c.d.o.OptplatformApplication The following profiles are active: ...

2018-05-18 16:14 3 27689 推薦指數:

查看詳情

mvn spring.profiles.active

Maven啟動指定Profile通過-P,如mvn spring-boot:run -Ptest,但這是Maven的Profile。 如果要指定spring-boot的spring.profiles.active,則必須使用mvn spring-boot:run -Drun.profiles ...

Thu Nov 21 00:18:00 CST 2019 0 364
springBoot 入門(二)—— 使用 spring.profiles.active來區分配置

背景很多時候,我們項目在開發環境和生成環境的環境配置是不一樣的,例如,數據庫配置,在開發的時候,我們一般用測試數據庫,而在生產環境的時候,我們是用正式的數據,這時候,我們可以利用profile在不同的環境下配置用不同的配置文件或者不同的配置。 spring boot 提供spring boot ...

Mon Apr 04 03:51:00 CST 2022 0 2614
springboot如何動態更換 配置文件 spring.profiles.active

maven可以動態更換配置文件,但是不同profile打包使用的命令不同, dev,test,prod就要打包3次, 如果項目是springboot的項目,就可以使用spring.profiles.active來進行一次打包,多個環節都可以運行。 下面就介紹下步驟: (1), 創建 ...

Sat Mar 24 04:11:00 CST 2018 0 1512
spring.profiles.active=@profiles.active@用法

1.引言 當在多配置文件,需要切換配置文件時,通常的做法都是修改激活的文件名稱,而spring.profiles.active=@profiles.active@ 是配合 maven profile進行選擇不同配置文件進行啟動,可以避免修改文件,而在maven打包是指定使用哪個配置文件 ...

Sun Jun 27 00:35:00 CST 2021 0 315
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM