What are the ways in which SpringBoot dynamically configures the Profile environment
Xiaobian to share with you the SpringBoot dynamic configuration Profile environment what are the ways, I believe most people do not know how, so share this article for everyone's reference, I hope you read this article after a great harvest, let's go to understand it!
The following example is an example of dynamically configured port numbers by modifying development and production environments:
Development environment port number is 8081
Production environment port number is 8082
Springboot configuration
Springboot has two configurations: properties and yaml or yml.
properties configuration
1. Configure the environment in application.properties.
Create two application-xx.properties
An application-dev.properties #development environment
An application-pro.properties #production environment
Modify in application.properties.
spring.profiles.active=pro #Switch to production
spring.profiles.active=dev #Switch to development environment
directory structure
2. Modify the environment configuration file by running the jar package
java -jar package file path--spring.profile.active=dev #Switch development environment
java -jar package file path--spring.profile.active =pro #Switch production environment
yaml mode configuration
yaml configuration is simpler than properties: a yaml file can replace the above three properties files; divide the environment by '---' three bars
#---These three bars are equivalent to creating multiple properties files---server: port: 8081spring: profiles: dev #specified environment name--server: port: 8082 spring: profiles: pro #specified environment name--- spring: profiles: active: pro #Configure Environment---
The above is "SpringBoot dynamic configuration Profile environment what are the ways" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!