关于intellij-idea:ideaspringboot热更新

3次阅读

共计 1044 个字符,预计需要花费 3 分钟才能阅读完成。

学习 java 曾经有一段时间了, 因为长时间应用 php 开发的起因, 觉的 idea 开发 java 时每次都要从新编译再重新启动切实是受不了, 太浪费时间了, google 下发现了个解决的路子

1、spring-boot-devtools

因为应用的是 spring-boot 开发的, 天然就会用到 spring-boot-devtools, maven 依赖如下:

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

增加这个依赖后, 我的项目发生变化的时候会进行热部署 (留神不是热加载哦). 当我门代码发生变化后, 手动 build 下我的项目达到热部署的成果 (也能够通过设置 idea 达到主动 build 的成果), 然而仍然要期待很久, 这不是我须要的; 对于 spring-boot-devtools 的具体介绍能够看下 https://pdai.tech/md/spring/springboot/springboot-x-hello-dev…

2、idea 其实自带的就有

这里先说下环境 macos + idea 的版本 2022.02(不同版本的设置有所不同)

stpe1、IntelliJ Idea -> settings -> HotSwap

step2、Edit Configurations, 找到对应 spring-boot 我的项目的 modify Options, 并依照下图操作

配置结束后, 当 idea 启动后再产生更改的时候, 只须要 build 一下能够了. 这里的 build 就是热更新, 速度还是比拟快的, 参考快捷键:
Mac -> Command + F9
Windows -> Ctrl + F9

ps: 集体比拟喜爱手动 build 来触发热更新, 这样对改变范畴多个文件的时候更敌对😄(因为保留一次触发一次也是麻烦), 如此一来开发速度失去了极大的晋升

3、踩坑点

1、应用 idea 自带的热更新的话, 记得把 spring-boot-devtools 这个依赖去掉哦, 否则从新编译我的项目会从新进行热部署哦

前面有的话再补充

4、成果展现

https://www.bilibili.com/video/BV1Vj421D795/?aid=1651243817&c…

5、参考:

https://cloud.tencent.com/developer/article/1683029

正文完
 0