JRebel的idea本地热加载和远程热加载

2020-11-03  本文已影响0人  CoderLJW

使用 JRebel 可以在修改代码后,动态重新加载修改的代码,免去了代码工程全量重建、重启的耗时流程,有效地提高开发者的效率。在 IDEA 的插件市场搜索 JRebel for IntelliJ 找到安装即可

1、热加载本地

推荐链接
https://www.cnblogs.com/bigshark/p/11343541.html
https://www.hexianwei.com/2019/07/10/jrebel%E6%BF%80%E6%B4%BB/
激活后,会自动配置JRebel的工程,跟随提示即可,完成后如图

image.png
@GetMapping(value = "/test")
    public RestResponse test(){
        return RestResponse.success("test 8888");
    }

2、远程热加载

- 下载JRebel,我这里下载的是最新版本
https://www.jrebel.com/products/jrebel/download/prev-releases
image.png
- 解压
unzip jrebel-2020.3.1-nosetup.zip

- 激活JRebel后,自动运行,这里使用上面的激活方式。产考官方给出的方式 https://manuals.jrebel.com/jrebel/standalone/activate.html#command-line-utility 查看Command line utility的激活方法。
./activate.sh https://jrebel.hexianwei.com/bbacb537-d186-4a29-9737-36a0e737235e 3344433@qq.com

- 设置密码 必须的
java -jar jrebel.jar -set-remote-password xxxx

这里服务器端设置JRebel设置完成
<?xml version="1.0" encoding="UTF-8"?>
<application generated-by="intellij" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_3.xsd">
    <id>meishi</id>
    <classpath>
        <dir name="/Users/paycloud110/sss/meishi/target/classes">
        </dir>
    </classpath>
</application>

rebel-remote.xml

<?xml version="1.0" encoding="UTF-8"?>
<rebel-remote xmlns="http://www.zeroturnaround.com/rebel/remote">
    <id>com.sailundipu.ljw.meishi</id>
</rebel-remote>
- 官网怎么运行项目
https://manuals.jrebel.com/jrebel/remoteserver/serverconfiguration.html
nohup java -agentpath:/usr/local/src/jrebel/lib/libjrebel64.so -Drebel.remoting_plugin=true -jar /usr/local/java/meishi_jar/meishi.jar >meishi.log &
2020-11-03 14:59:48 JRebel:  (c) Copyright 2007-2020 Perforce Software, Inc.
2020-11-03 14:59:48 JRebel:
2020-11-03 14:59:48 JRebel:  Over the last 1 days JRebel prevented
2020-11-03 14:59:48 JRebel:  at least 0 redeploys/restarts saving you about 0 hours.
2020-11-03 14:59:48 JRebel:
2020-11-03 14:59:48 JRebel:  JRebel started in remote server mode.
2020-11-03 14:59:48 JRebel:
2020-11-03 14:59:48 JRebel:
2020-11-03 14:59:48 JRebel:  #############################################################
2020-11-03 14:59:48 JRebel:
省了N多。。。。。。。。。。。。。。。。。
2020-11-03 15:00:04.669 [main] INFO  [org.springframework.boot.web.embedded.tomcat.TomcatWebServer:92]-Tomcat initialized with port(s): 9400 (http)
2020-11-03 15:00:04.776 [main] INFO  [org.apache.coyote.http11.Http11NioProtocol:173]-Initializing ProtocolHandler ["http-nio-9400"]
2020-11-03 15:00:04.778 [main] INFO  [org.apache.catalina.core.StandardService:173]-Starting service [Tomcat]
2020-11-03 15:00:04.779 [main] INFO  [org.apache.catalina.core.StandardEngine:173]-Starting Servlet engine: [Apache Tomcat/9.0.31]
2020-11-03 15:00:05.127 [main] INFO  [org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/]:173]-Initializing Spring embedded WebApplicationContext
2020-11-03 15:00:05.128 [main] INFO  [org.springframework.web.context.ContextLoader:284]-Root WebApplicationContext: initialization completed in 7456 ms
2020-11-03 15:00:10.117 [main] INFO  [org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor:181]-Initializing ExecutorService 'applicationTaskExecutor'
2020-11-03 15:00:10.214 [main] WARN  [org.springframework.boot.devtools.autoconfigure.OptionalLiveReloadServer:61]-Unable to start LiveReload server
2020-11-03 15:00:12.325 [main] INFO  [org.apache.coyote.http11.Http11NioProtocol:173]-Starting ProtocolHandler ["http-nio-9400"]
2020-11-03 15:00:12.420 [main] INFO  [org.springframework.boot.web.embedded.tomcat.TomcatWebServer:204]-Tomcat started on port(s): 9400 (http) with context path 
2020-11-03 15:00:12.432 [main] INFO  [com.sailundipu.ljw.shop.ShopApplication:61]-Started ShopApplication in 18.884 seconds (JVM running for 27.553)

注意:

nohup java -agentpath:/usr/local/src/jrebel/lib/libjrebel64.so -Drebel.remoting_plugin=true -jar /usr/local/java/meishi_jar/meishi.jar > meishi.log &
上一篇 下一篇

猜你喜欢

热点阅读