What is the difference between putting a property on application.yml or bootstrap.yml in spring boot? In logging.config case, the application works different.
This answer has been very beautifully explained in book "Microservices Interview Questions, For Java Developers (Spring Boot, Spring Cloud, Cloud Native Applications) by Munish Chandel, Version 1.30, 25.03.2018.
The following content has been taken from this book, and total credit for this answer goes to the Author of the book i.e. Munish Chandel
application.yml
application.yml/application.properties file is specific to Spring Boot applications. Unless you change the location of external properties of an application, spring boot will always load application.yml from the following location:
/src/main/resources/application.yml
You can store all the external properties for your application in this file. Common properties that are available in any Spring Boot project can be found at: https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html You can customize these properties as per your application needs. Sample file is shown below:
spring:
application:
name: foobar
datasource:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost/test
server:
port: 9000
bootstrap.yml
bootstrap.yml on the other hand is specific to spring-cloud-config and is loaded before the application.yml
bootstrap.yml is only needed if you are using Spring Cloud and your microservice configuration is stored on a remote Spring Cloud Config Server.
Important points about bootstrap.yml
spring.application.name: "application-name" spring.cloud.config.server.git.uri: "git-uri-config"
spring.application.name: spring.cloud.config.uri:
Upon startup, Spring Cloud makes an HTTP(S) call to the Spring Cloud Config Server with the name of the application and retrieves back that application’s configuration.
application.yml contains the default configuration for the microservice and any configuration retrieved (from cloud config server) during the bootstrap process will override configuration defined in application.yml