Spring5 - @ Indexed Spring annotation using @Indexed faster boot

 

Spring5 - @ Indexed notes

Spring5 - @ Indexed notes
original Crazypokerk_ finally released on 2019-08-02 17:05:01 reading number 639 Favorite
expand
the lead

Spring Framework 5.0 as the underlying core framework Spring Boot 2.0, it has now released version of view, relative to the Spring Framework 4.x, the annotation-driven performance is not so obvious. However, with the Spring Framework annotation capability can drive attention has been paid developers, especially in the Spring Boot application scenario, the extensive use of annotations @CompoentScan scan the specified package, when the long scanning package that contains classes, Spring annotation mode resolution It takes longer. For this problem, annotation @Indexed Spring Framework 5.0 version introduced for the Spring annotation mode to add indexes to improve application startup performance.
For chestnut:

@Indexed
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {}

However, notes @Indexed can not exist in isolation, the need to increase org.springframework in the project pom.xml: spring-context-indexer-dependent:

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-indexer</artifactId>
<optional>true</optional>
</dependency>

When packaged as a JAR engineering or re-built after the IDE tool, METE-INF / spring.components file is generated automatically. In other words, the file is generated at compile time. When the application execution context @CompoentScan Spring scanning, METE-INF / spring.components CandidateComponentsIndexLoader will be read and loaded into CandidateComponentsIndex objects, no further scanning @CompoentScan Package specified, but read CandidateComponentsIndex objects, so as to achieve lift performance purposes.
----------------
Disclaimer: This article is the original article CSDN bloggers "Crazypokerk_", and follow CC 4.0 BY copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/Crazypokerk_/article/details/98211897

 

Spring uses @Indexed faster boot

Spring @Indexed faster boot using
the original Dongguabai finally released on 2018-11-11 19:46:21 Reads 3063 collection
launched

Spring assembly read @Component (Derivation), implemented in two ways, one is reflective, one is ASM. Mainly reflecting lower performance to loadClass, after all Class, you need Load, such as scanning "com.dongguabai" need to put all the class load, efficiency is too slow.

ASM is equivalent resource information directly load classes, ReadResource.

Behind Spring5.0 there has been @Indexed, can be pre-compiled.

 

 

It generates spring.compoments file:

The same process with lombok at compile time.
----------------
Disclaimer: This article is the original article CSDN bloggers "Dongguabai", and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. .
Original link: https: //blog.csdn.net/Dongguabai/article/details/83961406

Guess you like

Origin www.cnblogs.com/hfultrastrong/p/12175152.html