- 使用spring-context-indexer 在编辑阶段预先生成文件,在启动节点不需要重新扫描,增加启动速度
注意事项:
多个模块,或者在引入jar 里面包括@Component的都需要在pom文件里面增加对应配置,否则启动会报错。
https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#beans-scanning-index
In this mode, all modules that are targets of component scanning must use this mechanism.
pom 文件增加配置
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-indexer</artifactId>
<version>5.3.22</version>
<optional>true</optional>
</dependency>
</dependencies>
本文介绍了如何通过在编辑阶段使用spring-context-indexer来预先生成组件索引文件,以避免启动时的扫描过程,从而加快Spring应用程序的启动速度。在多模块或多依赖包含@Component的情况下,需在每个模块的pom文件中添加相应配置,否则启动可能出错。添加依赖如下:<dependency><groupId>org.springframework</groupId><artifactId>spring-context-indexer</artifactId><version>5.3.22</version><optional>true</optional></dependency>。
1502

被折叠的 条评论
为什么被折叠?



