Several ways to specify the use of different configuration files in SpringBoot

Several ways to specify the use of different configuration files in SpringBoot

property file specification

Specify spring.profiles.active = dev in the configuration file

Specify the writing of the yaml file

Insert picture description here

Use the — symbol in yaml to divide the document block. The picture above is divided into three document blocks. If you do not specify which one to activate, the top document block will be used as the default configuration.

Specify by command line

After typing into a jar package, you can also specify the configuration file to be used when running
Insert picture description here

Virtual machine parameter specification
固定写法:-Dspring.profiles.active=dev

SpringBoot configuration file loading location

Insert picture description here

Insert picture description here

  • Command line configuration has the highest priority.
    Use command line to modify port number
    Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_43941676/article/details/108590727