【SpringBoot】使用 使用spring-context-indexer 注意事项

本文介绍了如何通过在编辑阶段使用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>。
  1. 使用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>
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值