spring-boot study five: Location Spring boot loader configuration file

1. The location of the configuration file is loaded

spring boot time will start to load the global configuration file application.properties (or application.yaml) file, the file in the default location:

 

 

 Under / relative path: the classpath. The addition profile than at resource, may also be in a position:

  • In classpath: the / config / i.e. resources / config;

 

 

  •  In the current project file config file folders;

 

 

  •  In the relative path of the current project:

 

 

 

2. loading sequence profile

The above mentioned four priority document is as follows:

 

 

 application.properties file can, and which is illustrated as a priority, more than four positions may be present in a spring boot project over a plurality of positions application.properties files, and multiple files will work, but the high-priority file overwrites the low priority document; complementary configuration;

 

 

 

3. To change the default configuration file location by spring.config.location

 This function is mainly project after packing, we can use the command line, the development of the new location of the configuration file to load at startup project, then load the file and specify the location of the project file to load the default work together to form a complementary document;

Specific use of the process as follows:

  • mvn clean install will be packaged into a jar engineering

 

  •  Switching the path to the jar package

 

  •  Find any local disk placement configuration file, the port number is set to 8805
  • Via the command line to load the local configuration file

 

 Note: spring boot2.0 version of the specified file with the default configuration does not complement the knowledge specified in the configuration file to take effect;

 

Guess you like

Origin www.cnblogs.com/haibaowang/p/11456310.html