已解决
spring boot 配置加载顺序
来自网友在路上 173873提问 提问时间:2023-10-22 15:58:22阅读次数: 73
最佳答案 问答题库738位专家为你答疑解惑
由官网的文档得知
https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.external-config
- Default properties (specified by setting SpringApplication.setDefaultProperties).
- @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.
- Config data (such as application.properties files).
- A RandomValuePropertySource that has properties only in random.*.
- OS environment variables.
- Java System properties (System.getProperties()).
- JNDI attributes from java:comp/env.
- ServletContext init parameters.
- ServletConfig init parameters.
- Properties from SPRING_APPLICATION_JSON (inline JSON embedded in an environment variable or system property).
- Command line arguments.
- properties attribute on your tests. Available on @SpringBootTest and the test annotations for testing a particular slice of your application.
- @DynamicPropertySource annotations in your tests.
- @TestPropertySource annotations on your tests.
- Devtools global settings properties in the $HOME/.config/spring-boot directory when devtools is active.
从第3步开始,加载 properties 文件中的配置,接下来第5步加载操作系统环境变量,第6步加载系统属性,第11步加载命令行参数。
如果同一个参数在前面声明了,后面也声明了同样的参数,后面的会覆盖前面的,即以后面的为准。
It is recommended to stick with one format for your entire application. If you have configuration files with both .properties and YAML format in the same location, .properties takes precedence.
如果 properties 和 yaml 文件都存在,properties 文件优先。
查看全文
99%的人还看了
相似问题
- 【Vue3】解决Vue打包后上传服务器 资源路径加载错误
- ArcGIS如何处理并加载Excel中坐标数据?
- JVM:字节码文件,类的生命周期,类加载器
- 从复杂大模型加载到3D PDF发布: EVGET HOOPS Framework如何助力高性能3D桌面应用开发?
- PHP手动为第三方类添加composer自动加载
- Arcgis 日常天坑问题2——三维场景不能不能加载kml图层,着手解决这个问题
- 如何在el-tree懒加载并且包含下级的情况下进行数据回显-02
- Arcgis js Api日常天坑问题3——加载geojson图层,元素无属性
- 深度学习(五)softmax 回归之:分类算法介绍,如何加载 Fashion-MINIST 数据集
- 【CASS精品教程】cass3d 11.0加载超大影像、三维模型、点云数据
猜你感兴趣
版权申明
本文"spring boot 配置加载顺序":http://eshow365.cn/6-21742-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!
- 上一篇: RabbitMQ队列及交换机的使用
- 下一篇: 【JVM系列】- 类加载子系统与加载过程