Get the App
SLTechnology News&Howtos  ›  Development  › 

How to understand Spring's thought of Registrar inversion

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

This article mainly introduces "how to understand Spring's Registrar inversion thought". In daily operation, I believe many people have doubts about how to understand Spring's Registrar inversion thought. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubt of "how to understand Spring's Registrar inversion thought". Next, please follow the editor to study!

The outline of this article

Version convention

Spring Framework:5.3.x

Spring Boot:2.4.x

Text

The above is to parse metadata by manually calling API to achieve the purpose of data formatting (conversion). In practical application scenarios, it is impossible for a business developer to directly manipulate API. After all, it is too unfriendly to developers and the threshold for use is too high.

Therefore, this article will introduce a more "advanced" use plan to see how Spring is integrated with high scalability, which is very developer-friendly. I believe this is also the most attractive part of Spring. Let's learn it together.

FormatterRegistry: registry

For multi-component management, the registry is a good solution.

FormatterRegistry is actually in: 9. Details can be found in the real chapter. The design of the Formatter registry is very clever. This article has been analyzed in great detail and learned its very clever design. By the way, it is recommended that you take a few minutes to take a look. At the end of this article, Brother A deliberately left a small tail: the registry's support for annotation factory AnnotationFormatterFactory, that is, this interface method:

FormatterRegistry: void addFormatterForFieldAnnotation (AnnotationFormatterFactory

Tags: Type format support interface method annotation component converter idea way capability learning design situation time service output importance foundation developer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Information MySQL Redmi OPPO Reno