java 调试热加载(解决重启动慢的问题)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/glw0223/article/details/87928958

环境

下载插件

http://hotcode.alibaba-inc.com/downloads/hotcode2-idea-plugin.zip

安装插件

IntelliJ IDEA > Preferences > Plugins > Install plugin from disk

然后重启 IDEA

启动或者停止hotcode

启动状态

停止状态

调试

1、在hotcode启动状态下,启动服务,会在控制台看到打印下面的信息,说明是开启的

======================================= HotCode2 ======================================
Hello, HotCode2 (Ver: 2.0.1.20171017034407) !!!
Start JVM with HotCode2 on Java_1.8.0_191-b12 @ JBoss-Mac OS X-10.14
    HotCode2  Path: /Users/gaoliwen/.hotcode2/agent/hotcode2.jar
    Web  Container: JBoss
Monitered Resource Paths :
    lcloud-lpm-control-start-1.0.0-SNAPSHOT.jar -----> /Users/gaoliwen/work/lcloud-lpm-control/lcloud-lpm-control-start/target/classes
Enabled Plugins: [sofamvc3_plugin, ibatis_plugin, mybatis_plugin, classmate_plugin, spring_plugin, sofarest_plugin, sofa3_plugin, webx3_plugin, sofamvc_plugin, hsf_plugin, webx2_plugin, sofa_plugin, velocity_plugin, hibernate_plugin, resteasy_plugin]
======================================= HotCode2 ======================================

2、测试

我的一个api

修改前

    @RequestMapping(value = "", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public ModelAndView version(HttpServletRequest request, HttpServletResponse response){
        String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
        log.info(uuid + " " + request.getRequestURI() + " " + "version " + this.VERSION);

        ModelAndView mav = new ModelAndView(jsonView);
        mav.addObject("uuid",uuid);
        mav.addObject("name", "xxxxxxx");
        mav.addObject("error_desc", "success");
        mav.addObject("error_code",0);
        mav.addObject("version", this.VERSION);
        mav.addObject("environment", environment);
        mav.addObject("method", request.getMethod());
        return mav;
    }

修改后(增加字段hotcode)

    @RequestMapping(value = "", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public ModelAndView version(HttpServletRequest request, HttpServletResponse response){
        String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
        log.info(uuid + " " + request.getRequestURI() + " " + "version " + this.VERSION);

        ModelAndView mav = new ModelAndView(jsonView);
        mav.addObject("uuid",uuid);
        mav.addObject("name", "lcloud-lpm-control");
        mav.addObject("error_desc", "success");
        mav.addObject("error_code",0);
        mav.addObject("version", this.VERSION);
        mav.addObject("environment", environment);
        mav.addObject("method", request.getMethod());
        mav.addObject("hotcode", "test");
        return mav;
    }

重新编译该类或者模块

猜你喜欢

转载自blog.csdn.net/glw0223/article/details/87928958