The java boot project understands the configuration files
in three formats. The three configuration file formats supported in the boot project we mentioned are
application.properties
application.yml
application.yaml
Among them, we also recommend that everyone use the application.yml format.
Then the question arises. If all three files exist in the resources directory, who will the system listen to?
It's very simple. We build all three files under resources
. application.properties set port number 80
application.yml set port number 81
application.yaml set port number 82
let's start it to see who is dominant
After starting, we look at the output information.
The starting port is 80.
It is obvious that the system uses application.properties
So the boss is application.properties,
let's kill application.properties now,
the boss has been confirmed, let's see who is the second child now?
Run the project again,
the startup port is 81, obviously the second one is application.yml
So let’s talk about all the configurations will take effect,
but if you have the same configuration, such as ports, etc., it will be loaded according to the priority. The
priority is
application.properties, the highest
application.yml, and the second
application.yaml is the lowest .