In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
The main content of this article is to explain "what is the function and function of custom starter". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what is the function and function of custom starter"?
The main function of custom starter is to automatically help us convert a JavaBean to SpringBean. In this process, the instantiation of some classes will rely on other classes. Considering whether it needs to be managed by Spring, there will be a lot of comments to help boot instantiate the object. For example, the @ ConfigurationProperties annotation in the picture matches the value of the property in the configuration file with the prefix sms to the attribute with the same name in the current class.
The @ EnableConfigurationProperties annotation in the following image means that the instantiation of Bean in the current class depends on the instance of the SmsProperties class, while the annotation of @ ConditionalOnProperties indicates that the current bean will only be instantiated if the corresponding attribute prefix exists in the configuration file and value is sign-name. MatchIfMissing means that if the prefix attribute does not exist, the default condition is not met, that is, it will not be instantiated.
After the above configuration is completed, you need to refer to the contents of starter. There are two ways in which starter takes effect:
1 、
2. The other is passive, which is captured by the application when the starter component is integrated into the Spring Boot application. The SPI mechanism similar to java is used here. Create a new META-INF/spring.factories to write the SmsAutoConfiguration fully qualified name under the autoconfigure resource pack. Multiple configuration classes are separated by commas and a backslash is used for line breaks.
Most starter is used in the second way, so if there are any classes in the project that can be directly injected or some configuration classes directly take effect, please don't be confused because the project refers to the corresponding starter.
At this point, I believe you have a deeper understanding of "what is the function and function of custom starter". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.