在我的應用程式 yml 中,我有兩個需要同時運行的組態檔
spring:
profiles:
active:
awss3, @env@
application:
name: CONFIG-SERVICE
我需要運行 awss3,無論環境是什么。這可能嗎 ?
uj5u.com熱心網友回復:
在我看來,您的要求符合 Profile Groups。這種方法更可取,因為它允許您直觀地通知開發人員哪些環境需要哪些組態檔。
https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.profiles.groups
示例:
spring:
profiles:
group:
production:
- "aws3"
- "prodmq"
然后您可以使用以下命令啟動應用程式:
--spring.profiles.active=production
為主動生產,aws3并prodmq在一重擊輪廓。
澄清:productiongroup: 下的關鍵字是您在運行應用程式時將使用的關鍵字spring.profiles.active=production
或者,您可以簡單地從命令列添加任何您想要的組態檔。
java -jar -Dspring.profiles.active=awss3,prodmq demo-0.0.1-SNAPSHOT.jar
uj5u.com熱心網友回復:
是的,使用屬性:
// Use your dynamic profile
spring.profiles.active=@env@
// Include your default profile
spring.profiles.include=awss3
亞姆:
spring:
profiles:
include: awss3
active:
@env@
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/390079.html
上一篇:SpringBootRestController中回傳void和ResponseEntity<Void>有什么區別?
