SpringBoot文档之Profiles的阅读笔记
1.SpringBoot文档之Developing的阅读笔记2.SpringBoot文档之入门的阅读笔记3.SpringBoot文档之Build Tool Plugins的阅读笔记4.SpringBoot文档之SpringApplication的阅读笔记5.SpringBoot文档之Externalized Configuration的阅读笔记
6.SpringBoot文档之Profiles的阅读笔记
7.SpringBoot文档之构建包的阅读笔记8.SpringBoot文档之测试框架的阅读笔记9.SpringBoot文档之消息系统的阅读笔记10.SpringBoot文档之IO的阅读笔记11.SpringBoot文档之Data的阅读笔记12.SpringBoot文档之Web的阅读笔记13.SpringBoot文档之Logging的阅读笔记14.SpringBoot文档之Jar文件格式的阅读笔记15.SpringBoot文档之配置参数的元数据的阅读笔记16.SpringBoot文档之开源软件依赖的阅读笔记17.SpringBoot文档之JSON的阅读笔记-
Profiles
类似Maven的Profile特性,限定配置项取值的生效场景。
在代码中,对于使用注解@Component
、@Configuration
、@ConfigurationProperties
标记的类,可以增加@Profile
,限定前述类的生效场景。类似如下样例代码,当启动时指定
Profile
为production
时生效。import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; @Configuration(proxyBeanMethods = false) @Profile("production") public class ProductionConfiguration { // ... } SpringBoot框架定义了如下属性:
spring.profiles.active
spring.profiles.default
spring.config.activate.on-profile
spring.profiles.include
可以通过配置文件、Java的系统属性、命令参数等方式来指定取值
可以在代码中使用
SpringApplication.setAdditionalProfiles
显式指定当前可用的Profile
。
本文来自博客园,作者:jackieathome,转载请注明原文链接:https://www.cnblogs.com/jackieathome/p/18366333
合集:
SpringBoot
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性