IDEA springboot项目热部署

小鱼儿 2022-05-09 04:18 376阅读 0赞

添加devtools依赖:

  1. <dependency>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-devtools</artifactId>
  4. <scope>true</scope>
  5. <optional>true</optional> <!-- 这个需要为 true 热部署才有效 -->
  6. </dependency>

JVM会定时扫描重新加载且仅加载有改动的类文件(.class文件),而不是加载所有的类文件,大大减少了类加载耗费的时间,从而实现热部署的功能。

Eclipse默认自动编译,而idea默认手动编译,因此idea需要修改两个参数以达到任意时间自动编译的目的。

1、File->setting->搜索compiler->将Build project automatically打勾(注意后面only works not running/debugging,所以我们要实现热部署就必须打破这个限制,于是乎有了下面设置)

2、CTRL+ALT+SHIFT+/ 组合键打开 Maintenance窗口选择Registry… ,找到compiler.automake.allow.when.app.running选项,打勾开启运行时编译功能

3、记得要关闭、重启IDEA后才会生效哦。

发表评论

表情:
评论列表 (有 0 条评论,376人围观)

还没有评论,来说两句吧...

相关阅读