添加依赖
打开项目的pom.xml
文件,在<dependencies>
标签内添加以下依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
如果你使用的是 Gradle 构建工具,则在build.gradle
文件中添加以下依赖:
implementation 'org.springframework.boot:spring-boot-devtools'
配置IDEA
在 IntelliJ IDEA 中,点击File
-> Settings
(Windows/Linux)或IntelliJ IDEA
-> Preferences
(Mac),打开设置窗口。在左侧菜单中选择Build, Execution, Deployment
-> Compiler
,勾选Build project automatically
选项。
勾选Advanced Srttings中的Allow auto-make to start even if developed application is currently running
ctrl+shift+a搜索并打开registry
ctrl+f搜索compiler.automake.postpone.when.idle.less.than,默认3000,值越小热部署生效越快,根据自己实际情况填写
springboot配置文件
application.properties
spring.devtools.restart.enabled=true
spring.devtools.restart.additional-paths=src/main/java,src/main/resources
或application.yml
spring:
devtools:
restart:
enabled: true
additional-paths: src/main/java,src/main/resources
暂无评论内容