如何优化SpringBoot的项目的启动速度
SpringBoot项目 如何 优化 启动 速度
2023-09-11 14:18:07 时间
日常开发SpringBoot项目启动类都用@SpringBootApplication,实际上它是下面三个注解的组合:
@EnableAutoConfiguration
: enable Spring Boot’s auto-configuration mechanism@ComponentScan
: enable@Component
scan on the package where the application is located (see the best practices)@Configuration
: allow to register extra beans in the context or import additional configuration classes
启动慢往往跟@ComponentScan和@EnableAutoConfiguration加载的内容太多有关,一种方法是不用这两个注解,通过@import注解精确指定要加载扫描的类,但要加载的类多时又很麻烦,
可以用@SpringBootApplication注解下面的属性:
- exclude: Exclude the list of classes from the auto configuration.
- excludeNames: Exclude the list of fully qualified class names from the auto configuration. This parameter added since spring boot 1.3.0.
- scanBasePackageClasses: Provide the list of classes that has to be applied for the @ComponentScan.
- scanBasePackages Provide the list of packages that has to be applied for the @ComponentScan. This parameter added since spring boot 1.3.0.
另外,如果SpringBoot项目启动很慢,可能意味着你要重新拆分微服务。
相关文章
- springboot项目:以run as-->spring boot app方式启动,配置热部署(亲测可用!!!)
- 创建第一个springboot项目,maven project
- springboot与springMVC的关系
- SpringBoot使用Nacos
- 基于IDEA创建SpringBoot项目并进行入门分析
- Apollo:服务端搭建、和SpringBoot集成
- SpringBoot 简单项目
- filebeat+kafka+Flink+ElasticSearch+springboot+高德地图热力图项目
- springboot项目如何打包给其他项目引用
- SpringBoot集成Elasticsearch
- Jenkins+Docker 一键自动化部署 SpringBoot 项目
- 创建springboot项目的三种方法(参考
- IDEA多个springboot项目启动修改端口
- Springboot搭建项目
- SpringBoot Maven多模块整合MyBatis 打包jar
- 如何在linux系统上部署SpringBoot项目
- springboot项目中使用Swagger
- 沙箱支付宝支付 SpringBoot+Vue前后端分离项目 实战
- springboot@Transactional事务多数据源的问题
- SpringBoot 整合 Druid Failed to configure a DataSource: 'url' attribute is not specified and no embed
- springboot项目打包、部署Tomcat流程详解
- springboot文件上传到本地电脑,项目目录,路径保存到数据库,页面显示上传的图片