spring boot 热启动
2024-08-31 16:53:02
spring boot热启动有两种方式
1. 以Maven插件的形式去加载,所以启动时使用通过Maven命令mvn spring-boot:run启动,而通过Application.run方式启动的会无效,因为通过应用程序启动时,已经绕开了Maven插件机制。
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.5.RELEASE</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build> 2. spring-boot-devtools
这种方式无论怎么启动应用,都可以达到修改文件后重启应用。
(1)、如果发现没有热部署效果,则需要检查IDE配置中有没有打开自动编译。
(2)、如果使用Thymeleaf模板引擎,需要把模板默认缓存设置为false
#禁止thymeleaf缓存(建议:开发环境设置为false,生成环境设置为true)
spring.thymeleaf.cache=false
(3)、针对devtools的可以指定目录或者排除目录来进行热部署
#添加那个目录的文件需要restart
spring.devtools.restart.additional-paths=src/main/java
#排除那个目录的文件不需要restart
spring.devtools.restart.exclude=static/**,public/**
(4)、默认情况下,/META-INF/maven,/META-INF/resources,/resources,/static,/templates,/public这些文件夹下的文件修改不会使应用重启,但是会重新加载(devtools内嵌了一个LiveReload Server,当资源发生改变时,浏览器刷新)
(5)、在application.properties中配置spring.devtools.restart.enabled=false,此时restart类加载器还会初始化,但不会监视文件更新。在SprintApplication.run之前调用System.setProperty(“spring.devtools.restart.enabled”, “false”);可以完全关闭重启支持。
最新文章
- react+redux教程(七)自定义redux中间件
- Android/Linux下CGroup框架分析及其使用
- Ubuntu配置OpenLDAP
- RAID 容量计算器
- 原生JavaScript实现mouseenter
- NoSQL分类及ehcache memcache redis 三大缓存的对比
- 54.xilinx_modelsim仿真错误1
- Java中数组复制的几种方法
- delphi 当月的第一天, 当月的最后一天
- UTF8 与 UTF16 编码
- Ehcache(2.9.x) - API Developer Guide, Basic Caching
- Linux只iptables
- Oracle、MySql、Sql Server比对
- python学习之 dictionary 、list、tuple操作
- bzoj 4539: [Hnoi2016]树
- 51nod 1575 Gcd and Lcm
- 【面试笔试算法】Program 3 : Complicated Expression(网易游戏笔试题)
- Java HttpURLConnection发送post请求示例
- Centos下查看当前目录大小及文件个数
- hdu 2063 给男女匹配 (匈牙利算法)
热门文章
- javascript ---(常用工具类的封装)
- [NOIP2009提高组]最优贸易
- Generational GC (Part one )
- 【转】 HtmlAgilityPack使用——XPath注意事项
- js获取css
- jsp静态引入(<;%@ include file=";";%>;) 乱码问题
- volatile的含义
- python list的+,+=,append,extend
- android系统又一次刷ROM简记(一)
- Weka中数据挖掘与机器学习系列之为什么要写Weka这一系列学习笔记?(一)