Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of multiple application Files in springboot

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report