系统环境:windows 10。
idea版本IntelliJ IDEA 2022.2.3 (Ultimate Edition)。
springBoot版:2.2.6.RELEASE。
Spring Boot开发应用程序时,需要频繁修改和调试代码。
为提高开发效率,希望能自动编译和热更新应用程序,在修改代码后,我们不需要手动重新启动应用程序。
org.springframework.boot。。groupId。>spring-boot-devtools。。artifactId。>runtime。。scope。>true。。optional。>。dependency。>
spring-boot-Springgdevtools依赖项目 Boot开发工具,它提供了自动编译和热更新的功能。
打开IDEA,选择“File” -> “Settings” -> “Build, Execution, Deployment” -> “Compiler”。
在右栏中,勾选“。Build project automatically。”选项。这样,在保存文件时,IDEA将自动触发编译过程。
IDEA,选择“Run” -> “Edit Configurations”。
在弹出对话框中,选择你的Spring boot应用程序配置
点击右侧“Modify options",找到“On frame deactivation选项,并选择“Update classes and resources”。
这样,在。IDEA失去了焦点。时,应用程序将自动更新类别和资源。
在IDEA中c;打开“src/main/java目录,并找到Spring 开始测试Boot应用程序的入口类。