Intelij IDEA + jRebel 如何配置基于 maven 的项目在 jetty 容器中的热部署? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
xiaofanz
V2EX    Java

Intelij IDEA + jRebel 如何配置基于 maven 的项目在 jetty 容器中的热部署?

  •  1
     
  •   xiaofanz 2016-03-24 09:09:02 +08:00 5530 次点击
    这是一个创建于 3539 天前的主题,其中的信息可能已经有所发展或是发生改变。
    昨天折腾到大半夜也没折腾出来 ,网上很多教程都不靠谱,要么都是太旧的版本
    (我当前用的 Intellij IDEA2016.1+jetty7)
    希望有经验的大神们指导一下,不甚感激!
    第1 条附言    2016-03-24 10:23:58 +08:00
    jetty context 下的 配置 item.xml 为:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

    <!-- ==================================================================
    Configure and deploy the test web application in $(jetty.home)/webapps/test

    Note. If this file did not exist or used a context path other that /test
    then the default configuration of jetty.xml would discover the test
    webapplication with a WebAppDeployer. By specifying a context in this
    directory, additional configuration may be specified and hot deployments
    detected.
    ===================================================================== -->

    <!--<Configure class="org.eclipse.jetty.webapp.WebAppContext">-->
    <Configure class="*">
    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    <!-- Required minimal context configuration : -->
    <!-- + contextPath -->
    <!-- + war OR resourceBase -->
    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

    <Set name="contextPath">/</Set>
    <Set name="war">/</Set>
    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    <!-- Optional context configuration -->
    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    <Set name="extractWAR">false</Set>
    <Set name="copyWebDir">false</Set>

    </Configure>
    22 条回复    2016-05-29 02:12:27 +08:00
    skyadmin
        1
    skyadmin  
       2016-03-24 09:36:15 +08:00   1
    同好奇,热部署咋搞……?是不是不用重新编译自动重新部署?
    YzSama
        2
    YzSama  
       2016-03-24 09:38:00 +08:00 via iPhone   1
    目前还在使用 idea14 。。热部署装好插件后,不是有两个 jr 按钮么?点击就是热部署了
    letitbesqzr
        3
    letitbesqzr  
       2016-03-24 09:39:21 +08:00   2
    直接点 jrebel 的启动不就可以了?

    @skyadmin jrebel 的原理是监控 class 目录的修改,一有修改就重载,比如改了 spring mvc 的 controller 不光会重载 还会自动调用去重扫 url 。支持的框架还是比较多。平时几乎都不重启
    YzSama
        4
    YzSama  
       2016-03-24 09:40:20 +08:00 via iPhone   1
    @skyadmin 你修改了 java 文件后,会自动重新编译修改的 java 文件为 class 。以至于不需要重新反覆重启编译项目所有文件
    xcaspar
        5
    xcaspar  
       2016-03-24 09:43:47 +08:00   1
    使用 JRebel 启动项目,更改代码后,编译项目即可,就会自动热部署。
    xiaofanz
        6
    xiaofanz  
    OP
       2016-03-24 09:46:41 +08:00
    @YzSama 确实有两个 jr 按钮,但是先需要添加一个 run/debug configuration, 请问这里面怎么配置呢?
    xiaofanz
        7
    xiaofanz  
    OP
       2016-03-24 09:47:03 +08:00
    @letitbesqzr jr 启动需要先添加一个 run/debug configuration, 请问这里面怎么配置呢?
    xiaofanz
        8
    xiaofanz  
    OP
       2016-03-24 09:47:26 +08:00
    @xcaspar jr 启动需要先添加一个 run/debug configuration, 请问这里面怎么配置呢?
    YzSama
        9
    YzSama  
       2016-03-24 09:50:02 +08:00 via iPhone
    @xiaofanz 我没用过 jetty ,我使用的是 tomcat 。我的部署方式和 eclipse 上差不多。。只是启动方式用 jr
    xiaofanz
        10
    xiaofanz  
    OP
       2016-03-24 09:51:44 +08:00
    @YzSama 恩,我以前也是用的 tomcat+jrebel 实现热部署,但是现在项目迁移到 maven 了,所以不知道怎么弄了,请问你使用的是 maven 吗?
    sorcerer
        11
    sorcerer  
       2016-03-24 09:54:01 +08:00 via iPhone
    官网上有说的,直接右键创建一个 jrebel 配置文件,然后就会自动在 resource 目录生成一个 jrebel.xml ……那个文件有 class 目录和 webapp 目录配置,根据你的实际情况修改就行了
    YzSama
        12
    YzSama  
       2016-03-24 09:54:31 +08:00
    @xiaofanz http://www.youmeek.com/intellij-idea-part-xviii-maven/
    你可以上这个网址看看。。我没使用 maven 部署项目,以前有用过。具体的配置应该不难。仔细琢磨下
    domty
        13
    domty  
       2016-03-24 09:58:02 +08:00
    我以前看到的是在 jetty 插件的配置文件里加信息,编写完 Java 代码快捷键重新编译,现在有更好的办法吗。
    低配置电脑重启次 jetty 要 70-90s ,太慢了。
    xiaofanz
        14
    xiaofanz  
    OP
       2016-03-24 09:59:00 +08:00
    @sorcerer rebel 文件 已经创建好了,但是这个 run/debug configuration 里面应该怎么配置呢?
    Suclogger
        15
    Suclogger  
       2016-03-24 10:01:43 +08:00
    @domty 我现在是停 jetty,mvn clean package -Dmaven.test.skip,再启 jetty,至少需要 5 分钟..太烦了..希望看到更好的方法
    crytis
        16
    crytis  
       2016-03-24 10:17:24 +08:00 via iPhone
    点击 build 菜单的 make project 就能重新加载,不用重启
    pelloz
        17
    pelloz  
       2016-03-24 11:34:26 +08:00
    除了想办法热部署以外,你应该写单元测试,这样就不用来回启动浪费时间了。
    ted05
        18
    ted05  
       2016-03-24 11:48:35 +08:00
    在 edit configurations 的 vm options 加上-noverify -javaagent:D:/Java/jrebel/jrebel.jar
    然后就可以用了。
    rannnn
        19
    rannnn  
       2016-03-24 12:58:38 +08:00
    难道不是原来怎么启动的 jrebel 就怎么启动么。。 0 配置啊
    sinsin
        20
    sinsin  
       2016-03-24 13:10:36 +08:00
    Suclogger
        21
    Suclogger  
       2016-03-24 23:38:57 +08:00
    有好办法了吗
    teemoer
        22
    teemoer  
       2016-05-29 02:12:27 +08:00
    @letitbesqzr 我擦 老大 我居然 半夜逛 V2EX 发现你了
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1102 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 32ms UTC 17:55 PVG 01:55 LAX 09:55 JFK 12:55
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86