After the jar package of the springBoot project, modify the configuration items in the configuration file

After the jar package of the springBoot project, the configuration file (application.properties) is encapsulated in the jar package, which is inconvenient to modify and other methods can be used.

Spring boot gives several locations to read the configuration file, we can use this method to modify the configuration file from outside the jar package.

 

When starting the jar package, springBoot will look for the configuration file in the following order.

1. Under the / config folder of the "current directory"

2. Under "Current Directory"

3. Under the / config folder of classpath

4. Under classpath

Remember, after we make an executable jar package , we usually start with a bat file. "Current directory" refers to the directory where the bat file is located, not the directory where the jar package is located! ! ! !

At the same time, when the configuration file is found, it will not continue to search, that is to say, the configuration file below the priority of the file will not be read, and it will stop when it is found.

 

Published 48 original articles · Like 36 · Visits 130,000+

Guess you like

Origin blog.csdn.net/weixin_42845682/article/details/97657214