springboot 读取properties的方式(17种) 待补充

官方文档奉上:

24. Externalized Configuration
--------官网内容--------

  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. RandomValuePropertySource that has properties only in random.*.
  12. Profile-specific application properties outside of your packaged jar (application-{profile}.properties and YAML variants).
  13. Profile-specific application properties packaged inside your jar (application-{profile}.properties and YAML variants).
  14. Application properties outside of your packaged jar (application.properties and YAML variants).
  15. Application properties packaged inside your jar (application.properties and YAML variants).
  16. @PropertySource annotations on your @Configuration classes. Please note that such property sources are not added to the Environment until the application context is being refreshed. This is too late to configure certain properties such as logging.* and spring.main.* which are read before refresh begins.
  17. Default properties (specified by setting SpringApplication.setDefaultProperties)

1. Devtools全局配置

2. 测试环境 @TestPropertySource 注解

3. 测试环境 properties 属性

4. 启动的命令行参数

5. SPRING_APPLICATION_JSON 的属性

6. ServletConfig 初始化参数

7. ServletContext 初始化参数

8. JNDI属性

9. Java系统属性

10. OS环境变量

11. RandomValuePropertySource 随机值属性

12. jar包外的application-{profile}.properties属性 (profile是做文件过滤的)

13. jar包内的application-{profile}.properties属性

14. jar包外的application.properties属性

15. jar包内的application.properties属性

16. @PropertySource 注解绑定

17. 默认属性 (SpringApplication.setDefaultProperties

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值