Spring Boot热部署

1.DevTools

引入devtools


      
          org.springframework.boot
          spring-boot-devtools
          true
      

DevTools会自动默认模板引擎的缓存为关闭状态
当类文件发生变化时,DevTools会监测到,并自动重启,比冷重启要快很多(使用IDEA时要build一下,eclipse配置auto build)

关闭热部署日志:spring.devtools.restart.log-condition-evaluation-delta=false
监控文件定制设置:
spring.devtools.restart.additionalpaths=custom/(额外监测文件)
spring.devtools.restart.exclude=static/
(不监测文件)

热部署触发时机:spring.devtools.restart.trigger-file=fileName ,只有当此文件发生变化时触发

devTools有两个类加载器,reload和base,reload里的类才会被热部署,jar默认都会在base加载器中加载,在多模块的工程中需要定制哪些jar加载,哪些不用
建文件META-INF/spring-devtools.properties,支持正则
restart.exclude.companycommonlibs=/mycorp-common-[\w-]+.jar(base加载)
restart.include.projectcommon=/mycorp-myproj-[\w-]+.jar(reload加载)

2.Jrebel
https://zeroturnaround.com/software/jrebel/

转自:https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/pdf/spring-boot-reference.pdf

你可能感兴趣的:(Spring Boot热部署)