IDEA配置热部署Devtools(开发必备技巧)

当你在开发是,仅仅只是修改了一个 Controller 或者修改某个 Javabean 中的内容等等,而要重新启动部署项目,这样不但要耗费时间,也使得开发效率大大降低,尤其是在一些大型开发工程中,这样的启动会更加明显。

这里便提出了热部署方式,在修改代码时不需要重新启动就能让后台代码起作用。

IDEA配置热部署分为五部:

1.添加 Devtools-jar 包到 project

使用 maven 直接导入。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <scope>runtime</scope>
    <optional>true</optional>
</dependency>

2.添加 plugin 到聚合父类总工程的 pom.xml 中

以 maven 的方式来操作构建的 springboot 项目。

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

3.在 IDEA 中开启自动编译的选项

将下面红圈的都打上√。
在这里插入图片描述

4.IDEA开启热注册

使用快捷键 shift+Ctrl+Alt+/,选择第一个 1.Registry…,红色线的选项打上√。
在这里插入图片描述

5.IDEA重启动生效

2019版之后可以不用启动。

发布了120 篇原创文章 · 获赞 16 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_43327091/article/details/104806770
今日推荐