Profile is Spring's support for providing different configuration functions for different environments, which can quickly switch environments by activating and specifying parameters.
1. Multiple Profile files (Properties format)
application.properties: Default global configuration file
application-dev.properties: development environment
application-prod.properties: Production environment
application-test.properties: test environment
server: port: 8080 spring: profiles: active: dev --- server: port: 8084 spring: profiles: dev --- server: port: 8085 spring: profiles: prod --- server: port: 8086 spring: profiles: test
3. Activate the specified Profile
to specify the current environment, and use the corresponding application-{profile}.properties or the configuration under the corresponding profile of application.yml as the configuration information used in the current environment.
spring.profiles.active=...
Virtual machine parameters: ---> ---->
Edit Configurations
VM options
-Dspring.profiles.active=...
Command Line:
packaging command
java -jar xxxx.jar --spring.profiles.active=...
IDEA run settings: ---> ---->
Edit Configurations
Program arguments
=====================Make an advertisement, welcome to pay attention =====================
QQ: |
412425870 |
WeChat public account: Cay Classroom |
|
csdn blog: |
http://blog.csdn.net/caychen |
Code cloud: |
https://gitee.com/caychen/ |
github: |
https://github.com/caychen |
Click on the group number or scan the QR code to join the QQ group: |
|
Click on the group number or scan the QR code to join the QQ group: |