SpringBoot如何使用Profile配置多环境支持

2024-11-03 15:26:43

1、Profile是Spring对不同环境提供不同配置功能的支持,可以通过激活、指定参数等方式快速切换环境1、多profile文件形式: -格式:app造婷用痃lication-{profile}.properties。 application-dev.properties、application-properties2、多profile文档块模式3、激活方式: -命令行:--spring.profiles.active=dev -配置文件:spring.profiles.active=dev -jvm参数:-Dspring.profiles.active=dev

SpringBoot如何使用Profile配置多环境支持

3、我们可以在application.properties中指定要激活的配置文件。server.port=8081spring.profiles.active=dev

SpringBoot如何使用Profile配置多环境支持

6、我们还可以在运行主程序的时候指定需要激活的配置。

SpringBoot如何使用Profile配置多环境支持
猜你喜欢