Background: The same set of Spring Boot applications will be installed in different environments, such as: development, testing, production, etc. Among them, the most modified ones are nothing more than the configuration of the database address, server port, etc.
Use the profile function to switch between different operating environments (production environment, development environment, and test environment)
yml file
yml configuration file naming method
application-dev.yml
application-pro.yml
application-test.yml
Here we must pay attention to the dash
yml file writing method
spring:
#切换项目环节 active 的值 dev 当前运行环境配置文件后缀
profiles:
active: dev
The above code corresponds to the application-dev.yml file
properties file
properties configuration file naming method
application-dev.properties
application-pro.properties
application-test.properties
Here we must pay attention to the dash
Properties file writing method
spring.profiles.active=dev