Explain the multi environment configuration of spring boot configuration file in detail
I Benefits of multi environment configuration:
1. Different parameters can be configured for different environment configurations~
2. Facilitate deployment, improve efficiency and reduce errors~
II Properties multi environment configuration
1. Configure activation options
2. Add other profiles
application. properties:
When running, you can also set the activated environment
3、 Yaml multi environment configuration
1. Configure activation options
2. Add three dashes in English status to the configuration file to distinguish
application. yml
In this case, an error is reported: duplicate key: spring
Correct configuration:
4、 Comparison of two configuration methods
1. To configure multiple environments for properties, you need to add multiple configuration files, and yaml only needs one accessory file
The YML file itself has the ability to distinguish between different environments
2. The difference of writing format, yaml is relatively simple and elegant
3. Yaml's disadvantage: it cannot be loaded through @ propertysource annotation. If you need to load values using the @ propertysource annotation, use the properties file.
Seriously, do you still like the configuration form of properties and the elegance of YML form? No feeling ~ ha ha~
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.