spring.profiles.active
和spring.config.activate.on-profile
的确切区别是什么?"警告","消息":"属性 'spring.profiles' 从位置 '类路径资源[application.yaml]' 导入无效,应该用 'spring.config.activate.on-profile' 替换 [来源: 类路径资源[application.yaml]
spring.profiles.active
和spring.config.activate.on-profile
的确切区别是什么?"警告","消息":"属性 'spring.profiles' 从位置 '类路径资源[application.yaml]' 导入无效,应该用 'spring.config.activate.on-profile' 替换 [来源: 类路径资源[application.yaml]
spring.profiles.active
可以用于指定哪些配置文件始终处于活动状态。
以下是文档中的示例:
spring:
profiles:
active: "production"
spring.config.activate.on-profile
(在Spring Boot 2.4之前被称为spring.profiles
)可以用于标记配置文件片段是特定于某个profile的。
来自文档的一个示例:
server: port: 9000 --- spring: config: activate: on-profile: "development" server: port: 9001 --- spring: config: activate: on-profile: "production" server: port: 0
In the preceding example, the default port is 9000. However, if the Spring profile called ‘development’ is active, then the port is 9001. If ‘production’ is active, then the port is 0.
Spring Boot 2.4 中的另一个变化是不再允许在 spring.config.activate.on-profile
的组合中使用 spring.profiles.active
属性。(有关详细信息,请参见此博客文章。)