IDEA2022.3开启热部署
1、开启IDEA的自动编译
1.1 具体步骤:打开顶部工具栏 File -> Settings -> Build,Execution,Deployment -> Compiler 然后勾选 Build project automatically 。
1.2 打开顶部工具栏 File -> Settings -> Advanced Settings -> Compiler -> 然后勾选 Allow auto-make to start even if developed application is currently running。
2、开启IDEA的热部署策略(非常重要)
2.1具体步骤:点击Edit COnfigurations...
2.2选择Modif options -> On 'Updata' actrion -> Update classes and resources
3、在pom.xml文件中导入热部署插件
3.1.添加devtools jar包到pom.xml
<!-- spring-boot-devtools --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><optional>true</optional> <!-- 表示依赖不会传递 --></dependency>
3.2.添加plugin到pom.xml
<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>2.5.15</version><configuration><fork>true</fork> <!-- 如果没有该配置,devtools不会生效 --></configuration><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin>