最近在搞springboot前后端分离的项目,用到springboot项目,每次改代码都要重启下很烦,于是寻找可以实现热部署的方法
归纳如下
1.spring-boot-devtools
2.spring-loaded
3.Jrebel(本文重点)
1.在pom中直接引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
设置以下两项(第一项如已设置直接设置第二项)
1) “File” -> “Settings” -> “Build,Execution,Deplyment” -> “Compiler”,选中打勾 “Build project automatically” 。
2) 组合键:“Shift+Ctrl+Alt+/” ,选择 “Registry” ,选中打勾 “compiler.automake.allow.when.app.running” 。
2.在Plugins中添加依赖
<build>
<plugins>
<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>
</plugin>
</plugins>
</build>
3.Jrebel
由于我不想在代码中引入热部署内容于是乎就用的这一种
1)idea下载Jrebel插件
2)重启idea
3) Jrebel是收费的 要下载一个exe文件,首先在github上下载一个exe文件,(用来破解jrebel)https://github.com/ilanyu/ReverseProxy/releases/tag/v1.0
打开exe文件不要关闭
4)激活
第一行:http://127.0.0.1:8888/ 后面的一串字母叫GUID,JRebel授权地址有GUID检测
第二行:随意写个邮箱,格式正确即可。
5)然后将JRebel设置为离线模式,可以180天内不用再次激活,如下图
6)使用
靠红色框右边的就是debug,到这里就可以使用springboot热部署了