SpringBoot系列之外部配置用法简介

本文简要介绍SpringBoot外部配置的常用方法,包括命令行参数、环境变量、配置文件等。按照优先级从高到低排序,高优先级配置会覆盖低优先级。外部配置文件如`application.properties`或`application.yml`,可以分为jar包内外和带有/不带profile的,其中jar外部的profile配置优先级最高。理解配置文件加载顺序有助于有效管理应用配置。
摘要由CSDN通过智能技术生成

SpringBoot系列之外部配置用法简介

引用Springboot官方文档的说法,官方文档总共列举了如下用法:

1、Devtools global settings properties on your home directory (~/.spring-boot-devtools.properties when devtools is active).
2、@TestPropertySource annotations on your tests.
3、properties attribute on your tests. Available on @SpringBootTest and the test annotations for testing a particular slice of your application.
4、Command line arguments.
5、Properties from SPRING_APPLICATION_JSON (inline JSON embedded in an environment variable or system property).
6、ServletConfig init parameters.
7、ServletContext init parameters.
8、JNDI attributes from java:comp/env.
9、Java System properties (System.getProperties()).
10、OS environment variables.
11、A RandomValuePropertySource that has properties only in random.*.
12、Profile-specific application properties outside of your packaged jar (application-{profile}.properties and YAM

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

smileNicky

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值