Spring Boot 配置文件中读取变量的优先级

Spring Boot About 325 words

常用的优先级

优先级从高到低。IDEA中模拟环境变量可以从Edit Configurations中添加Environment variables中添加,以;封号隔开。

  • JVM环境变量
  • 命令行
  • SPRING_APPLICATION_JSON(命令行/环境变量/系统变量中设置的JSON字符串,需压缩为一行)
  • 系统环境变量
  • 配置文件(application.yaml

完整的优先级

可从官方文档中查看,官方文档按优先级从低到高排序。

官方文档

https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.external-config

Views: 796 · Posted: 2023-02-06

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh