专注于 JetBrains IDEA 全家桶,永久激活,教程
持续更新 PyCharm,IDEA,WebStorm,PhpStorm,DataGrip,RubyMine,CLion,AppCode 永久激活教程

idea使用devtools进行热部署springboot项目

1、更改idea配置
1) “File” -> “Settings” -> “Build,Execution,Deplyment” -> “Compiler”,选中打勾 “Build project automatically” 。
2) 组合键:“Shift+Ctrl+Alt+/” ,选择 “Registry” ,选中打勾 “compiler.automake.allow.when.app.running”

2、项目中导入spring-boot-devtools包

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

3、application.properties配置文件添加配置项

#排除那个目录的文件不需要restart
spring.devtools.restart.exclude=static/**
spring.devtools.restart.additional-exclude=static/**,public/**
#需要开启热部署的文件目录
spring.devtools.restart.additional-paths=src/main/java
spring.devtools.restart.enabled=true
spring.devtools.add-properties=false
spring.profiles.active=dev

#禁用前端插件缓存,如thymeleaf或freemarker
spring.thymeleaf.cache=false

4、如果浏览器页面没有更新,如Chrome可禁用缓存
F12或者“Ctrl+Shift+I”,打开开发者工具,“Network” 选项卡下 选中打勾 “Disable Cache(while DevTools is open)”

源码示例:https://gitee.com/lion123/springboot-thymeleaf-demo

文章永久链接:https://tech.souyunku.com/24987

未经允许不得转载:搜云库技术团队 » idea使用devtools进行热部署springboot项目

JetBrains 全家桶,激活、破解、教程

提供 JetBrains 全家桶激活码、注册码、破解补丁下载及详细激活教程,支持 IntelliJ IDEA、PyCharm、WebStorm 等工具的永久激活。无论是破解教程,还是最新激活码,均可免费获得,帮助开发者解决常见激活问题,确保轻松破解并快速使用 JetBrains 软件。获取免费的破解补丁和激活码,快速解决激活难题,全面覆盖 2024/2025 版本!

联系我们联系我们