JAVA热启动插件Jrebel

方案一:Jrebel(推荐)
IDE(STS或Idea)安装Jrebel插件
title

下面介绍如何获取Jrebel的激活码,注意Jrebel激活码使用时会连接服务器实时监测,一个账号只允许一个终端使用;
1. 打开https://my.jrebel.com(需要翻墙),需要第三方facebook或twitter账号登录后进行授权
title
2. 需要填写个人资料(手机什么的可以瞎填目前没有做校验);
title
title
3. 注册成功后就可以获取到免费的激活码
title
4. 输入IDE->Jrebel->Activation code完成激活;

使用Jrebel热启动:
1. 如图:
title
2. 启动信息:

Connected to the target VM, address: '127.0.0.1:58146', transport: 'socket'
2017-11-02 09:52:46 JRebel: Directory '/Users/Robert/gitlab/terra-service/service/target/classes' will be monitored for changes.
2017-11-02 09:52:46 JRebel: Contacting myJRebel server ..
2017-11-02 09:52:51 JRebel: 
2017-11-02 09:52:51 JRebel: A newer version '7.1.1' is available for download 
2017-11-02 09:52:51 JRebel: from http://zeroturnaround.com/software/jrebel/download/
2017-11-02 09:52:51 JRebel: 
2017-11-02 09:52:56 JRebel:  Starting logging to file: /Users/Robert/.jrebel/jrebel.log
2017-11-02 09:52:56 JRebel:  
2017-11-02 09:52:56 JRebel:  #############################################################
2017-11-02 09:52:56 JRebel:  
2017-11-02 09:52:56 JRebel:  JRebel Agent 7.1.0 (201709271413)
2017-11-02 09:52:56 JRebel:  (c) Copyright ZeroTurnaround AS, Estonia, Tartu.
2017-11-02 09:52:56 JRebel:  
2017-11-02 09:52:56 JRebel:  Over the last 30 days JRebel prevented
2017-11-02 09:52:56 JRebel:  at least 50 redeploys/restarts saving you about 2 hours.
2017-11-02 09:52:56 JRebel:  
2017-11-02 09:52:56 JRebel:  Over the last 180 days JRebel prevented
2017-11-02 09:52:56 JRebel:  at least 569 redeploys/restarts saving you about 23.1 hours.
2017-11-02 09:52:56 JRebel:  
2017-11-02 09:52:56 JRebel:  **Licensed to Youbao Luo (using myJRebel)**.
2017-11-02 09:52:56 JRebel:  
2017-11-02 09:52:56 JRebel:  
2017-11-02 09:52:56 JRebel:  #############################################################
2017-11-02 09:52:56 JRebel:  
09:53:04,217 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]

注意:idea修改源码后热部署前需要触发重新编译快捷键ctrl+f9

方案二:spring-loaded
spring-loaded有两种集成方式
1. spring-loaded热插拔设置,首先下载springloaded然后配置JVM启动参数
Run As->Run Configurations…->Java Application->->Arguments(VM arguments)
add:
-javaagent:/Users/Robert/.springloaded/springloaded-1.2.6.RELEASE.jar -noverify

  1. 使用maven pluin,然后使用 mvn spring-boot:run启动工程
<plugins>
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <dependencies>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>springloaded</artifactId>
                <version>1.2.3.RELEASE</version>
            </dependency>
        </dependencies>
    </plugin>
</plugins>

个人推荐使用Jrebel,功能比springloaded更强大也更稳定,支持热部署class和部分配置文件及XML(具体可以自行尝试),最新版的Jrebel可能不支持免费的注册码

猜你喜欢

转载自blog.csdn.net/luoyoub/article/details/80062438