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”);可以完全关闭重启支持。

最新文章

  1. react+redux教程(七)自定义redux中间件
  2. Android/Linux下CGroup框架分析及其使用
  3. Ubuntu配置OpenLDAP
  4. RAID 容量计算器
  5. 原生JavaScript实现mouseenter
  6. NoSQL分类及ehcache memcache redis 三大缓存的对比
  7. 54.xilinx_modelsim仿真错误1
  8. Java中数组复制的几种方法
  9. delphi 当月的第一天, 当月的最后一天
  10. UTF8 与 UTF16 编码
  11. Ehcache(2.9.x) - API Developer Guide, Basic Caching
  12. Linux只iptables
  13. Oracle、MySql、Sql Server比对
  14. python学习之 dictionary 、list、tuple操作
  15. bzoj 4539: [Hnoi2016]树
  16. 51nod 1575 Gcd and Lcm
  17. 【面试笔试算法】Program 3 : Complicated Expression(网易游戏笔试题)
  18. Java HttpURLConnection发送post请求示例
  19. Centos下查看当前目录大小及文件个数
  20. hdu 2063 给男女匹配 (匈牙利算法)

热门文章

  1. javascript ---(常用工具类的封装)
  2. [NOIP2009提高组]最优贸易
  3. Generational GC (Part one )
  4. 【转】 HtmlAgilityPack使用——XPath注意事项
  5. js获取css
  6. jsp静态引入(&lt;%@ include file=&quot;&quot;%&gt;) 乱码问题
  7. volatile的含义
  8. python list的+,+=,append,extend
  9. android系统又一次刷ROM简记(一)
  10. Weka中数据挖掘与机器学习系列之为什么要写Weka这一系列学习笔记?(一)