Based on spring boot, different environments use different configuration methods

Spring multi file configuration:

1. Properties file

2. Yaml file

1、 Properties file

In spring boot, the file name of multi environment configuration needs to meet the requirements of application - {profile}

Properties format, where {profile} corresponds to your environment ID, as shown below.

• application dev.properties: development environment.

• application-test. Properties: test environment.

• application-prod.properties: production environment.

As for which configuration file will be loaded, you need to go to app giant CA giant on Properties file

spring. profiles. Active property, whose value corresponds to the {profile} value in the configuration file. as

spring. profiles. Active = test will load application test Properties configuration

File content.

2、 Yaml file

usage method:

Use different profiles by specifying startup parameters, such as:

Test environment: Java - jar XXX jar Cspring. profiles. active=test

Production environment: Java - jar XXX jar Cspring. profiles. active=prod

The above article uses different configuration methods based on different environments of spring boot, which is all the content shared by Xiaobian. I hope it can give you a reference and support more programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>