【问题标题】:Spring Boot: How to create 3 profiles and implement in spring bootSpring Boot:如何创建3个配置文件并在spring boot中实现
【发布时间】:2023-02-06 14:30:45
【问题描述】:

我想根据环境创建 3 个配置文件来访问数据库

而不是将所有属性写在一个文件中。我希望属性必须根据环境(Qlty、Prod、Dev)分成 3 个。那是

1.application_prod.properties --should contain all production related details
2.application_qlty.properties --should contain all qlty related details
3.application_dev.properties  --should contain all dev related details

如何在spring boot中实现以上3个profile,以及如何根据环境类型选择profile。以简单的方式实施上述内容的最佳做法是什么

【问题讨论】:

  • 你打算怎么运行它?
  • 那是一个maven项目吗?

标签: java spring profile boot


【解决方案1】:

您只需在运行选项中添加配置文件

java -jar app.jar --spring.profiles.active=dev

或与行家

mvn spring-boot:run -Dspring-boot.run.arguments="--spring.profiles.active=dev"

一句话。属性文件上的配置文件写入“-”

application-dev.properties

【讨论】:

    猜你喜欢
    • 2021-12-31
    • 2019-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多