热启动 :https://blog.youkuaiyun.com/dujianxiong/article/details/78957701
热部署:https://blog.youkuaiyun.com/zemochen/article/details/53327518
springloaded
Pom.xml中直接在spring-boot插件中添加依赖即可:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<!-- spring热部署 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
</dependencies>
<!-- 设置入口类
<configuration>
<mainClass>cn.springboot.Mainspringboot</mainClass>
</configuration>
-->
</plugin>
- 运行:
maven命令行:
$ mvn clean spring-boot:run
IDEA启动设置:
spring-boot:run
- 改动后,编译即可实现热部署
- 由于使用IDE的不同,编译快捷键也可能不同,笔者实用intellij idea ,对应快捷键 Ctrl+Shift+F9,也可以设置自动编译(见这篇文章),eclipse 没记错的话是默认自动编译
或者直接通过 SpringBootApplication 的main方法启动,修改后重新编译代码效果一样。
注意:
热部署只针对方法内的代码修改。如果是增加方法和类,或者修改方法上注解的内容是不能立即生效的。
热启动可以让所有修改的代码生效,但是性能会低很多。
根据自己的情况二选一使用。