官方文档:https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-profiles

1、概述

为了简化多环境适配应用场景的操作,Spring Boot 提供了 Profile 功能。

在开发时,配置文件里的信息用的都是开发环境下的,比如数据库的,缓存的等等。
但在部署时,需要连接到线上生产环境的数据库和缓存,此时就需要将开发环境的配置修改为线上生产环境的配置再打包部署。

使用 Spring Boot 提供的 profile 功能,可以快速的进行环境切换。