spring boot of application profiles

   The last time we had seen each other on this document, and he had a few simple configuration. It has two configurations, one application.properties, is application.yml a file, you need to keep in mind, when two files are present, spring boot using the default file application.properties. The name of the configuration file can not be changed is the application. But in the actual project, we will have multiple environments, each environment has its own different information, this time we need to use multi-file configuration.

      At that time, we can create multiple environments with multiple files when configured according to the profile situations, such as application-dev.properties, application-uat.properties, application-test.properties three configuration environment. The naming convention is behind application- add the name of the environment you need. Then the specific documents which take effect, you need to define in application.properties file:

spring.profiles.active=dev

At this time, dev file with the extension would take effect. If the master file exists, the file also exists dev configuration information, the information in dev file is correct. If the dev does not exist, the main configuration file is still in force.

      

Guess you like

Origin www.cnblogs.com/wanghq1994/p/12109094.html