Springboot multi-environment development and configuration file priority

1 springboot multi-environment setting switch

1.1 Create corresponding configuration files separately

1.2 In  application . properties: spring.profies.active=environment name

1.3 .yml files are the same, so I won't write them here.

2 Configuration file priority

2.1 SpringBoot configuration files can be placed in multiple paths, and the configuration priority under different paths is different

Configuration file directory, which can be placed in the directory (priority from high to low)

file:./config/ (under the current project path config directory);

file:./ (under the current project path);

classpath:/config/ (under the classpath config directory);

classpath:/ (under the classpath config).

The priority is from high to low, and the configuration with high priority will overwrite the configuration with low priority;

SpringBoot will load configuration files from these four locations and configure complementary configurations;

2.2   Command line parameters The priority of command line parameters is the highest. Assuming that the startup port number configured in the highest priority configuration file of the internal configuration is 8081, the startup command line parameters are as follows:

java -jar springboot-demo-0.0.1-SNAPSHOT.jar --server.port=8012

This piece is briefly recorded.

 

Guess you like

Origin blog.csdn.net/huzhiliayanghao/article/details/107001970