Idea springboot springCloud热加载热调试常用的两种方式

场景描述

在项目开发的过程中,需要修改调试的时候偶每次都需要重启项目浪费时间,下面是我整理的两种常用的两种方式

方式一

修改启动配置方式(主要针对debug模式下)
点击启动配置=》edit configrations…

在这里插入图片描述

configration下面修改Updateclasses and resources
on ‘update‘ action:当用户主动执行更新的时候更新 快捷键:Ctrl + F9

on frame deactication:在编辑窗口失去焦点的时候更新
在这里插入图片描述
在这里插入图片描述

方式二

SpringBoot-dev-tools热部署
说明
当开发者将 spring-boot-devtools 引入项目后,只要 classpath 路径下发生变化,项目就会自动重启,这极大地提高了项目的开发速度。如果开发者使用 Eclipse ,那么在修改完代码并保存之后,项目将自动编译井触发重启,而开发者如果使用 IntelliJ IDEA 默认情况下,需要开发者手动编译才会触发重启。手动编译时,单击 Build -> Build Project 菜单或者按 Ctrl+F9 快捷键进行编译,编译成功后就会触发项目重启。当然,使用 IntelliJ IDEA 开发者也可以配置项目自动编译,配置步骤:

1.idea 启动自动编译
File=》Settings=》Build,Execution,Deployment=》 Compiler=》勾选Build project automeatically
在这里插入图片描述

Ctrl+shifter+alt+/ =》Registry=》勾选compiler.automake.allow.parallel
在这里插入图片描述
在这里插入图片描述

2.引入jar

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

3.application.properties文件添加配置

#热部署默认会重启
spring.devtools.restart.enabled=true
#添加那个目录的文件需要restart
spring.devtools.restart.additional-paths=src/main/java
#排除那个目录的文件不需要restart
spring.devtools.restart.exclude=static/**,public/**

猜你喜欢

转载自blog.csdn.net/A_awen/article/details/129431300