1、前言
在进行spring boot开发时,如果修改了接口方法都要重启服务来测试,这样比较麻烦,那么有spring boot热部署插件,修改方法后只需重新编译项目即可生效。这里简单记录一下我所用的插件
2、添加依赖
<!--热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
3、重新编译项目
重新编译文件 Ctrl+Shift+F9或者编译项目 Ctrl+F9 后生效
4、如果热部署插件加入后报错
Binding to target [Bindable@516195cf type = org.springframework.boot.autoconfigure.web.ResourceProperties, value = 'provided', annotations = array<Annotation>[@org.springframework.boot.context.properties.ConfigurationProperties(prefix=spring.resources, value=spring.resources, ignoreInvalidFields=false, ignoreUnknownFields=false)]] failed:
Property: spring.resources.cache-period
Value: 0
Origin: "spring.resources.cache-period" from property source "refresh"
Reason: The elements [spring.resources.cache-period] were left unbound.
spring boot版本与devtools不兼容,需要升级devtools版本即可
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>