首页  

Springboot devtools 简介     所属分类 springboot 浏览量 274
支持热部署,修改代码后 无需重启springboot应用  
使用 两个ClassLoader
一个Classloader加载那些不会改变的类(譬如第三方Jar包)
另一个ClassLoader加载会更改的类,称为restart ClassLoader
代码更改时,原来的restart ClassLoader 被丢弃
重新创建一个restart ClassLoader
由于需要加载的类比较少,可以实现快速重启

The restart technology provided by Spring Boot works by using two classloaders. 
Classes that do not change (for example, those from third-party jars) are loaded into a base classloader. 
Classes that you are actively developing are loaded into a restart classloader.

When the application is restarted, the restart classloader is thrown away and a new one is created. 
This approach means that application restarts are typically much faster than “cold starts”, 
since the base classloader is already available and populated.


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

optional true  防止依赖传递到其他模块中

application.properties
spring.devtools.restart.enabled=false 
restart类加载器还会初始化,但不会监听文件更新

在SprintApplication.run之前调用
System.setProperty(“spring.devtools.restart.enabled”, “false”)
可以完全关闭重启支持

spring.devtools.restart.enabled=true
# spring.devtools.restart.additional-paths=src/main/java
# WEB-INF文件夹内容修改不重启
spring.devtools.restart.exclude=WEB-INF/**


org.springframework.boot.devtools.filewatch.FileSystemWatcher org.springframework.boot.devtools.restart.classloader.RestartClassLoader org.springframework.boot.devtools.autoconfigure.LocalDevToolsAutoConfiguration

上一篇     下一篇
正态分布和幂律分布

javascript json 格式化

苏轼与王安石

springboot2 集成 prometheus

springboot 加载指定的 properties文件

Java8 Stream过滤null值