SpringBoot yml我怎么能同时运行两个配置文件
SpringBoot yml how can I run two profiles at the same time
在我的应用程序 yml 中,我需要两个配置文件 运行
spring:
profiles:
active:
awss3, @env@
application:
name: CONFIG-SERVICE
我需要 awss3 运行,无论环境如何。这可能吗?
在我看来,您的要求符合配置文件组。这种方法更可取,因为它允许您直观地告知开发人员哪些环境需要哪些 配置文件。
示例:
spring:
profiles:
group:
production:
- "aws3"
- "prodmq"
然后您可以使用以下方式启动应用程序:
--spring.profiles.active=production
要激活生产,aws3
和 prodmq
个人资料一击而得。
澄清一下:group: 下的关键字 production
是您 运行 作为 spring.profiles.active=production
申请时将使用的关键字
或者您可以简单地从命令行添加您想要的任何配置文件。
java -jar -Dspring.profiles.active=awss3,prodmq demo-0.0.1-SNAPSHOT.jar
是的,使用属性:
// Use your dynamic profile
spring.profiles.active=@env@
// Include your default profile
spring.profiles.include=awss3
yaml:
spring:
profiles:
include: awss3
active:
@env@
在我的应用程序 yml 中,我需要两个配置文件 运行
spring:
profiles:
active:
awss3, @env@
application:
name: CONFIG-SERVICE
我需要 awss3 运行,无论环境如何。这可能吗?
在我看来,您的要求符合配置文件组。这种方法更可取,因为它允许您直观地告知开发人员哪些环境需要哪些 配置文件。
示例:
spring:
profiles:
group:
production:
- "aws3"
- "prodmq"
然后您可以使用以下方式启动应用程序:
--spring.profiles.active=production
要激活生产,aws3
和 prodmq
个人资料一击而得。
澄清一下:group: 下的关键字 production
是您 运行 作为 spring.profiles.active=production
或者您可以简单地从命令行添加您想要的任何配置文件。
java -jar -Dspring.profiles.active=awss3,prodmq demo-0.0.1-SNAPSHOT.jar
是的,使用属性:
// Use your dynamic profile
spring.profiles.active=@env@
// Include your default profile
spring.profiles.include=awss3
yaml:
spring:
profiles:
include: awss3
active:
@env@