Spring Boot's system configuration file loading order

【Introduction to Theory】

Configuration file loading order:

1. The config directory under the project root directory. 【Highest priority】
2. The root directory of the project.
3. The config directory under the classpath.
4. Classpath directory (the default location of application.properties when creating a new project). [lowest priority]

Remarks:
Loading order: 4 -> 3 -> 2 -> 1.
Priority: Decrease gradually (1>2>3>4).


【for example】

Example project structure:

1. The config directory under the project root directory ( file:./config/ ): helloworld /config/
2. The project root directory ( file:./ ): helloworld /
3. The config directory under the classpath ( classpath:/config/ ) : helloworld /src/main/resources/config/
4. classpath directory ( classpath:/

Guess you like

Origin blog.csdn.net/Shipley_Leo/article/details/128174689