1. Project internal configuration file
Spring boot will scan the application.properties or application.yml file in the following location as the default configuration file of Spring boot
The priority of the properties file under the same target is greater than the yml file
file: ./config/ (current project path config directory);
file: ./ (under the current project path);
classpath: / config / (under the classpath config directory);
classpath: / (under classpath config).
The above is in order of priority from high to low, all files in the location will be loaded, and the high-priority configuration content will override the low-priority configuration content.
SpringBoot will load the main configuration file from all four locations. If the properties of the configuration file in the high priority and the low priority configuration file do not conflict, they will co-exist- complementary configuration.
We can see from the ConfigFileApplicationListener class , where the DEFAULT_SEARCH_LOCATIONS property sets the loaded directory: