【问题标题】:Are Spring Profiles and Spring Boot Profiles the same?Spring Profiles 和 Spring Boot Profiles 是一样的吗?
【发布时间】:2016-08-09 11:25:46
【问题描述】:

Here 是关于 Spring Boot 配置文件的描述,here 是 Spring 配置文件描述。乍一看,如果需要使用配置文件,可以在没有 Spring Boot 的情况下使用。那么 Spring Boot 是否为 Spring Profile 提供了额外的 Profile 功能?

【问题讨论】:

  • 差不多,但是 Spring boot 为配置文件带来了额外的功能,比如配置文件配置属性(通过使用 application-.properties),并允许您使用spring.profiles.active 属性。
  • @g00glen00b 为什么你没有提供这个作为答案?我认为你应该:)

标签: java spring spring-boot spring-profiles


【解决方案1】:

它们是相同的东西,即配置文件配置。但是,Spring boot 确实为 Spring 配置文件带来了一些额外的功能,例如:

  • 您可以使用application-<profile name>.properties(或.yml)文件为每个配置文件单独提供应用程序属性。例如,如果您创建一个名为 application-test.properties 的文件并使用此配置文件运行应用程序,Spring boot 也会加载这些配置属性
  • Spring boot 也有一个名为 spring.profiles.active 的配置属性,允许您配置应用于 Spring boot 应用程序的配置文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-17
    • 2020-05-22
    • 2020-10-08
    • 2014-04-16
    • 1970-01-01
    • 1970-01-01
    • 2016-01-19
    相关资源
    最近更新 更多