Springboot multi-environment configuration

Applications generally will be installed in several different environments (such as development, testing, production, etc.), each environment will have some parameters are not the same.

Spring Boot have also provided support, as long as the name of the configuration file application-{profile}.yamlformat to which {profile}a corresponding identification of the environment:

  • application-dev.yaml: Development Environment

  • application-test.yaml: test environment

  • application-prod.yaml: Production Environment

Thereafter, necessary to application.yamlset the configuration attribute spring.profiles.active, whose value corresponds to {profile}value.

Such as: spring.profile.active: devIn this case it will be loaded application.yamland the application-dev.yamlcontents of the two profiles, two files if the same attribute, use can application-dev.yamlvalues.

 

However, if you do not set spring.profiles.active, or use the application.yaml configuration!


Reference Links: https://www.jianshu.com/p/21f9541e17d9

Guess you like

Origin www.cnblogs.com/mediocreWorld/p/11846963.html