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 > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to understand the @ Indexed decryption of spring5". In the daily operation, I believe many people have doubts about how to understand the @ Indexed decryption of spring5. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how to understand the @ Indexed decryption of spring5"! Next, please follow the editor to study!
With the native development of the cloud, many technologies will be reconsidered and redefined, and the development of technology has always been in the right place at the right time to enjoy its benefits. Under Yunyuan, the biggest problem with jdk is that it is bulky (hundreds of mb) and starts slowly, while like the Serverless architecture, the NodeJS technology stack is more perfect.
In fact, the essence of advocating modularization in jdk9 is to reduce the size of JVM, and there is no need for resources (Jar) to be loaded, and there is also a solution to the problem of slow startup (a similar to HotSpot VM). Its advanced point lies in shortening the running cost and compiling .java files directly into native code, while jvm has one more step, first compiling .java files into bytecode (.class). And then compiled into native code with the help of JVM runtime JIT technology.
Spring5.0 starts to support @ Indexed to speed up the startup of the application, and builds index files through Annotation Processing Tools API at compile time. The essence is to solve the problem of long loading time of Bean scan at startup by static.
What is Annotation Processing Tools API?
It's not cool techs. As mentioned in the previous series, it's kind of like lombok.
Which resources will be indexed?
Classes marked as Component and its derived annotations (Controller, Repository, Service, Configuration, and so on) are supported by default, but they can also be non-spring bean (@ Indexed modified classes).
Note: if it is already a spring bean (Component-decorated class, and Component has been marked @ Indexed), there is no need to mark @ Indexed, otherwise the index file will append the same one, which feels like a bug
How to use it?
To use it very much, just add dependencies, and a META-INF/spring.components will be generated by default after install.
Org.springframework spring-context-indexer true#spring.componentscom.yh.rfe.lucky.day.service.impl.BasCostReportServiceImpl=org.springframework.stereotype.Componentcom.yh.rfe.lucky.day.service.impl.BasShopRuleDetailServiceImpl=org.springframework.stereotype.Component
While CandidateComponentsIndexer is responsible for generating index files for qualified comments, the entire source code is not particularly complex, through three components: StereotypesProvider, MetadataCollector, MetadataStore to complete.
Public class CandidateComponentsIndexer implements Processor {@ Override public synchronized void init (ProcessingEnvironment env) {this.stereotypesProviders = getStereotypesProviders (env); this.typeHelper = new TypeHelper (env); this.metadataStore = new MetadataStore (env); this.metadataCollector = new MetadataCollector (env, this.metadataStore.readMetadata ());} @ Override public boolean process (Set...) AnnotatedClasses) {Assert.notEmpty (annotatedClasses, "At least one annotated class must be specified"); this.reader.register (annotatedClasses);}}
In fact, there are still some limitations in the implementation of @ Indexed (only a module for the current maven, in other words, it is based on jar). There is still a lot of work to be done based on the entire project file, especially the org.springframework package (there are a lot of jar of bean to be loaded into ioc below), and the authorities haven't considered it yet.
At this point, the study on "how to understand the @ Indexed decryption of spring5" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.