SpringBoot project configuration file loading location

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:

  1. MySpringBoot/config
  2. MYSpringBoot: root directory
  3. MySpringBoot/src/main/resources/config
  4. 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!

Published 381 original articles · praised 85 · 80,000 views +

Guess you like

Origin blog.csdn.net/weixin_40763897/article/details/105129957