From 20ed8c2ec319fcde3ada038afa6a027b096d7cd0 Mon Sep 17 00:00:00 2001 From: Robert Smith <58187843+robert-smith-911@users.noreply.github.com> Date: Mon, 15 Feb 2021 19:13:45 -0500 Subject: [PATCH 1/2] Document precedence between properties and yaml See gh-25300 --- .../src/docs/asciidoc/spring-boot-features.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc index 67ee5c5ae5..6344262524 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc @@ -522,6 +522,8 @@ Config data files are considered in the following order: . <> outside of your packaged jar (`application.properties` and YAML variants). . <> outside of your packaged jar (`application-\{profile}.properties` and YAML variants). +NOTE: If you have both `application.yml` and `application.properties` on the same level, the `application.properties` will take precedence. + To provide a concrete example, suppose you develop a `@Component` that uses a `name` property, as shown in the following example: [source,java,indent=0] From 63cca9b8c6aed2d578f4893b603c1efea79f2233 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 1 Mar 2021 10:44:43 +0100 Subject: [PATCH 2/2] Polish "Document precedence between properties and yaml" See gh-25300 --- .../src/docs/asciidoc/spring-boot-features.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc index 6344262524..cdd6728b34 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc @@ -522,7 +522,8 @@ Config data files are considered in the following order: . <> outside of your packaged jar (`application.properties` and YAML variants). . <> outside of your packaged jar (`application-\{profile}.properties` and YAML variants). -NOTE: If you have both `application.yml` and `application.properties` on the same level, the `application.properties` will take precedence. +NOTE: It is recommended to stick with one format for your entire application. +If you have configuration files with both `.properties` and `.yml` format in the same location, `.properties` takes precedence. To provide a concrete example, suppose you develop a `@Component` that uses a `name` property, as shown in the following example: