The configuration file of our SpringBoot project can be arranged in four places, taking the SpringBoot project MySpringBoot as an example and arranging from highest to lowest, as follows:
- MySpringBoot/config
- MYSpringBoot: root directory
- MySpringBoot/src/main/resources/config
- MySpringBoot/src/main/resources
Configuration files can be placed in these locations, and the optimization level is loaded as shown above, and they will complement each other. That is to say, if there are configuration items in the configuration file, those with higher optimization levels will override those with lower priorities.
It can be seen from the above that the optimization level of the configuration file under config in the same level directory is higher than that of the outside.
We can also publish the jar package and dynamically specify other configuration files outside the project through –spring.config.location, which is particularly useful for operation and maintenance personnel:
java -jar MySpringboot-1.0-SNAPSHOT.jar --spring.config.location=/home/kyun/Desktop/application.properties
thanks for reading!