| 1️⃣ |
命令行参数 (--key=value) |
✅ 覆盖所有 |
| 2️⃣ |
系统环境变量 (KEY=VALUE) |
✅ 覆盖除命令行外的所有 |
| 3️⃣ |
Java 系统属性 (-Dkey=value) |
✅ 覆盖除前两项外 |
| 4️⃣ |
Spring Cloud 远程配置(如 Nacos、Config Server、Consul、Vault)通过 spring.config.import 引入 |
✅ 覆盖几乎所有本地配置 |
| 5️⃣ |
application-{profile}.properties(外部) |
✅ 覆盖内部配置及低于它的配置 |
| 6️⃣ |
application.properties(外部) |
✅ 覆盖内部配置及低于它的配置 |
| 7️⃣ |
application-{profile}.properties(内部) |
✅ 覆盖内部默认配置及低于它的配置 |
| 8️⃣ |
application.properties(内部) |
❌ 容易被上面的覆盖 |
| 9️⃣ |
spring.config.import 引入的本地配置文件(如 file:./config/local-config.yaml 或 classpath:/another-config.properties) |
❌ 可能被上面的覆盖 |
| 🔟 |
@PropertySource 注解引入的配置文件 |
❌ 最容易被覆盖 |