Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of multiple application Files in springboot

Shulou Source: shulou.com Published: 2022-06-03 08:38:10 11月03日 Update

Editor to share with you a number of application files in springboot example analysis, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

Springboot multiple application files

The configuration of production deployment is often different from that of testing. If they are all modified in an application.properties file, they are not only prone to omissions, but also troublesome over and over again.

If springboot's profiles is used to distinguish between production and testing, then a lot of unnecessary work can be reduced, and the configuration that needs to be modified is often just one or two sentences.

1. Create production and test files as follows

2. Application.properties is configured as follows

Note:

1. Spring.profiles.active is used to activate springboot multi-file configuration.

Multi-environment configuration file names need to meet the naming rules of application-xxx.properties in springboot

The xxx is exactly the name of the configuration file that our spring.profiles.active needs to specify.

2. Which configuration do you want to use? modify the spring.profiles.active tag of the application.properties main configuration file.

3. Load multiple configuration files spring.profiles.active = xxx,xxx

For example: spring.profiles.active = test,database

Springboot splits application.yml into multiple

Like this

Application- {}. Yml

Specify the currently running environment in application.yml

Spring: profiles: active: dev

Then you can set up different databases in different environments

Such as:

The above is all the contents of the article "sample Analysis of multiple application Files in springboot". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: File configuration multiple environment article test production example analysis different content file name repetition not much most of that is data database is in more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Shulou Tech Info NVidia Shulou Information Huawei