IDEA 热部署- 自动编译设置
原文:https://www.cnblogs.com/TechSnail/p/7690829.html && https://blog.csdn.net/qq_31293575/article/details/80654132
扩展:
https://blog.csdn.net/diaomeng11/article/details/73826564
https://blog.csdn.net/z15732621582/article/details/79439359 : bean.xml配置的项目
https://blog.csdn.net/u011499747/article/details/71746325 : <excludeDevtools>false</excludeDevtools>为了安全 远程应用排除 devtools
===前言===start==========================================================
spring boot 热部署devtools实现
1.devtools
spring为开发者提供了一个名为spring-boot-devtools的模块来使Spring Boot应用支持热部署,提高开发者的开发效率,无需手动重启Spring Boot应用。
2.项目搭建
本文是采用IDEA搭建的Spring Boot应用,通过spring-boot-devtools配置,可以支持修改java文件会自动重启程序,一些资源无需触发重启,例如thymeleaf模板文件就可以实时编辑。默认情况下,更改/META-INF/maven,/META-INF/resources ,/resources ,/static ,/public 或/templates下的资源不会触发重启,而是触发livereload。devtools模块包含一个嵌入的livereload服务器,可以在资源变化时用来触发浏览器刷新。浏览器需要在livereload.com下载安装扩展。 例如Chrome浏览器在应用商店安装livereload插件后,在要自动刷新的页面点击对应的图标,启动应用后更新页面内容或者css等都会触发页面自动刷新。
3.livereload
livereload 通过引入的脚本livereload.js在 livereload 服务和浏览器之间建立了一个 WebSocket 连接。每当监测到文件的变动,livereload 服务就会向浏览器发送一个信号,浏览器收到信号后就刷新页面,实现了实时刷新的效果。每次启动时,需要点击对应的图标,如下图所示。

4.项目代码配置
(1)pom.xml配置文件
|
1
2
3
4
5
6
7
8
9
10
11
12
|
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional></dependency><plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 --> </configuration></plugin> |
(2)yml配置
|
1
2
3
4
5
6
|
devtools: livereload: enabled: true #是否支持livereload port: 35729 restart: enabled: true #是否支持热部署 |
1.引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<!-- optional=true, 依赖不会传递, 该项目依赖devtools;
之后依赖boot项目的项目如果想要使用devtools, 需要重新引入 -->
<optional>true</optional>
</dependency>
===前言===end==========================================================
2.配置文件
#开启或者关闭freemarker和thymeleaf的页面缓存
spring.freemarker.cache=false
spring.thymeleaf.cache=true
spring.devtools.restart.enabled=true
#需要开启热部署的文件目录
spring.devtools.restart.additional-paths=src/main/java
#使用了mybatis好像需要设置,应该没有必要。且生产环境需要移除
#restart.include.mapper=/mapper-[\\w-\\.]+jar
#restart.include.pagehelper=/pagehelper-[\\w-\\.]+jar
#静态文件下不需要重启
#spring.devtools.restart.exclude=static/**,public/**
#spring.devtools.restart.exclude=WEB-INF/**
3.更改idea配置
1) “File” -> “Settings” -> “Build,Execution,Deplyment” -> “Compiler”,选中打勾 “Build project automatically” 。
2) 组合键:“Shift+Ctrl+Alt+/” ,选择 “Registry” ,选中打勾 “compiler.automake.allow.when.app.running”

4.Chrome禁用缓存(如果还是无法使用)
F12或者“Ctrl+Shift+I”,打开开发者工具,“Network” 选项卡下 选中打勾 “Disable Cache(while DevTools is open)”
IDEA 热部署- 自动编译设置的更多相关文章
- IDEA+Tomcat热部署自动编译
https://www.cnblogs.com/1024zy/p/6344000.html 之前太傻瓜了,一直以为用了IDEA改了类或者js的时候全都要手动构建发布,其实不用,IDEA这么好的工具怎么 ...
- idea热部署+自动编译
https://blog.csdn.net/z15732621582/article/details/79439359
- Thymeleaf学习记录(2)--自动编译设置
了方便每次修改HTML文件都能实时刷新,做一下更改. 在application.properties文件加入以下命令: #thymeleaf start spring.thymeleaf.mode=H ...
- IDEA热部署自动重启服务问题
新接手项目过于庞大,从eclipse果断换成了IDEA.因为IDEA有免费的热部署,咳咳咳... 但是,手贱的我在下面这张状态下,直接OK了,TM,这不是我要的热部署啊,这是重新启动啊,但是勾选了do ...
- IDEA自动编译设置
ctrl+alt+s: ctrl+shift+alt+/:
- 在IDEA上对SpringBoot项目配置Devtools实现热部署
spring为开发者提供了一个名为spring-boot-devtools的模块来使Spring Boot应用支持热部署,提高开发者的开发效率,无需手动重启Spring Boot应用. devtool ...
- SpringBoot添加热部署
一.导入依赖 <!--热部署--> <dependency> <groupId>org.springframework.boot</groupId> & ...
- Jrebel实现tomcat热部署,遇到的问题以及解决办法,详解
我的安装的详细过程: 下载Jrebel: https://github.com/ilanyu/ReverseProxy/releases/tag/v1.4 我的是winx64,所以选择如下的: 下载 ...
- maven 使用之自动编译热部署设置
参见创建webapp项目 eclipse Maven 使用记录 ------ 建立 webapp项目 在maven中为实现热部署设置,部署至webapp,即webroot 设置classes输出目的地 ...
随机推荐
- Linux command nmon
Linux command nmon [Purpose] Learning linux command nmon [Eevironment] Ubuntu 16.04 ...
- JAVA按数字,字母排序,但不包括大小写和汉字排序
public class ABC { public static void main(String[] args) { new ABC().sortStringArray(); } public vo ...
- 通过滑动条控制Cube旋转
private float speed = 10; private float speedValue; private GameObject slider; private GameObject cu ...
- windows添加PDF虚拟打印机
添加PDF虚拟打印机(果真姜还是老的辣,我摸索了两天没结果的事情,大佬轻轻松松两分钟搞定...) 这种PDF虚拟打印机的功能是将需要被打印的内容写到当前系统的指定目录下的指定文件中.整个过程都不需要连 ...
- C/C++知识补充(2) C/C++操作符/运算符的优先级 & 结合性
, 逗号操作符 for( i = 0, j = 0; i < 10; i++, j++ ) ... 从左到右 Precedence Operator Description Example ...
- ngnix笔记
ngnix可通过-s 参数控制,如quit正常退出:reload重载配置文件,具体参考:http://nginx.org/en/docs/switches.html ngnix的指令解释请参考这里:h ...
- Eclipse几点常用设置+个人喜好
1.代码自动提示 在我们忘记方法名或者想偷懒时,代码自动提示很管用.不过Eclipse默认是输入"."后才会出现包或类成员的提示,也就意味着我们必须先输入一个完整的类名,提示才能出 ...
- Oracle学习(四)_SQL函数
--第一部分:SQL基础 --ch1 简单查询 --ch2 查询基本概念 --ch3 数据过滤 --第二部分:多表操作 --ch4 集合理论 --ch5 内连接 --ch6 外连接 --ch7 子查询 ...
- css 利用border 绘制三角形. triangle
1.基础三角形. <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...
- ob 函数的使用
ob 函数的使用1. 页面静态化 $id = isset($_GET['id'])?$_GET['id']-0:0; $filename = "html/".date(" ...