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

What are the complete steps for SpringBoot to load a configuration file

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

Share

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

This article introduces to you what is the complete step of SpringBoot loading configuration file, the content is very detailed, interested friends can refer to it, hope to be helpful to you.

Where does SpringBoot start loading configuration files?

The entry for SpringBoot to load the configuration file is entered by the ApplicationEnvironmentPreparedEvent event, and SpringBoot will obtain the instance class of ApplicationListener through the spring.factories file in the constructor of SpringApplication:

Public SpringApplication (ResourceLoader resourceLoader, Class... PrimarySources) {... SetListeners ((Collection) getSpringFactoriesInstances (ApplicationListener.class));

There is a ConfigFileApplicationListener class in spring.factories that listens to ApplicationEnvironmentPreparedEvent and then loads the configuration file:

# Application Listenersorg.springframework.context.ApplicationListener= org.springframework.boot.context.config.ConfigFileApplicationListener...

Once you have the event and event handling class, you can find out where the event is sent, and you can figure out how SpringBoot loads the configuration file. SpringBoot initializes the SpringApplicationRunListeners class before starting. It implements the SpringApplicationRunListener interface and forwards the event:

Class SpringApplicationRunListeners {private final Log log; private final List listeners; SpringApplicationRunListeners (Log log, Collection)

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