SpringBoot实现IDEA热部署是否有启动速率提升?

1. dev-tool

maven依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>TestDemo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.2.RELEASE</version>
    </parent>
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!--devtools热部署-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
            <scope>true</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <fork>true</fork>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

配置

spring:
  devtools:
    restart:
      enabled: true  #设置开启热部署
      additional-paths: src/main/java #重启目录
      exclude: WEB-INF/**
  freemarker:
    cache: false    #页面不加载缓存,修改即时生效

IDEA配置

在这里插入图片描述
快捷键
ctrl + alt+ shift + /
在这里插入图片描述
在 首字母c开头中找:
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

问题

看控制台打印,打印了两边banner。据我所知,这两遍banner Spring容器启动了两次。
感觉还是不太ok。

测试启动速率

@SpringBootApplication
public class TestApplication {
    public static void main(String[] args) {
        long before = System.currentTimeMillis();
        SpringApplication.run(TestApplication.class, args);
        System.out.println(System.currentTimeMillis()-before);
    }
}

初次启动:
在这里插入图片描述
热部署启动:
在这里插入图片描述
因为我的测试项目没什么类,但是也可明显看到启动速率减少了很多。但是实际启动速率也要考虑很多反面,热部署可能只是减少了本地类的加载速率,但是启动涉及到微服务其他方面,比如说注册服务,启动的其他预处理操作的话,可能根本就改善不了什么启动速率,因为根本就和项目是否臃肿是否无关 了。所以我想这也是为什么公司项目没有采用dev-tool的关系。

另一个路子

Control+Shift+F9进行手工免启动快速更新!!
测试和热部署容器速率差不多。

2.JRebel插件

首先就是下载安装以及破解插件,过程省略。失效请重复以下过程。

https://jrebel.qekang.com/{uuid}
UUID
在这里插入图片描述
设置离线工作模式:
在这里插入图片描述
如果上面的Dev-tool的IDEA 配置已经配置好了的话,就不用再配置了。

测试

初次启动
在这里插入图片描述
但是在我修改了部分代码后,貌似并没有重启。
在这里插入图片描述
芜湖,真乃神器。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值