In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about the usefulness of spring-context-indexer dependency in Spring. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Spring spring-context-indexer depends on org.springframework spring-context-indexer 5.2.0.RELEASE true
Although classpath scanning is very fast, there are a large number of classes within Spring, and adding this dependency can improve the startup performance of large applications by creating a static list of candidate objects at compile time.
In this mode, all modules that are the target of component scanning must use this mechanism.
Configure springboot to automatically open the browser spring-context-indexer principle int port= 8080 X string portPrefix = "--server.port="; for (String arg: args) {if (arg.startsWith (portPrefix)) {port= Integer.parseInt (arg.substring (portPrefix.length ();} SpringApplication.run (AppRegisterApplication.class, args); try {Runtime.getRuntime (). Exec ("cmd / c start string + port) } catch (IOException e) {e.printStackTrace ();}
Now the springboot project in use is large, and each startup is very slow, so speed up startup with the following dependencies:
Spring-context-indexer
Description
1. Although classpath scanning is very fast, there are a large number of classes within Spring, and adding this dependency can improve the startup performance of large applications by creating a static list of candidate objects at compile time.
two。 However, in this mode, all modules that are the target of component scanning must use this mechanism. Only then.
3. You need more than spring5 to use it. The test is valid. The dependence is as follows:
Org.springframework spring-context-indexer 5.2.0.RELEASE true
Then add a note to your startup class: @ Indexed, which means that if you open the index, it will speed up the startup of the project.
Description of the principle:
Let's first look at the official explanation:
After @ Indexed is used in the project, the META-INT/spring.components file is automatically generated in the project when you compile the package.
When the Spring application context performs a ComponentScan scan, the META-INT/spring.components will be read and loaded by CandidateComponentsIndexLoader and converted into a CandidateComponentsIndex object, so @ ComponentScan will not scan the specified package, but read the CandidateComponentsIndex object, thus improving performance.
Pay attention to the use
Although this @ Indexed annotation can improve performance, you should also pay attention to it when using it.
Assuming that there is only pattern annotations in an a.jarreb. Jar containing META-INT/spring.components resources in the Spring application, the pattern annotations in the b.jar will not be recognized when scanning the package in both JAR with @ ComponentScan.
Please be sure to pay attention to such problems.
Thank you for reading! This is the end of this article on "what is the use of spring-context-indexer dependence in Spring?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.