Problem Description:
In springboot project may have a test environment, development environment, production environment, these environments, we may have to use a different configuration, if every time you switch the environment to be re-write a configuration file is very troublesome, it is provided below a method for fast and easy switching configurations under different circumstances.
solution:
1, first created in the resources directory complete configuration files (including test, development, configuration files in the production environment), and then create a application.yml file because springboot project at startup will load the default configuration file parsing the contents
2, the configuration in application.yml at the contents, springboot will automatically parse the application-XXX.yml configuration files at startup
. 1 Spring:
2 Profiles:
. 3 Active: pro // followed by the name of the representative pro here above step application-