xiaofanz
V2EX  ›  Java

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

  •  1
     
  •   xiaofanz · Mar 24, 2016 · 5853 views
    This topic created in 3717 days ago, the information mentioned may be changed or developed.
    昨天折腾到大半夜也没折腾出来 ,网上很多教程都不靠谱,要么都是太旧的版本
    (我当前用的 Intellij IDEA2016.1+jetty7)
    希望有经验的大神们指导一下,不甚感激!
    Supplement 1  ·  Mar 24, 2016
    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 replies    2016-05-29 02:12:27 +08:00
    skyadmin
        1
    skyadmin  
       Mar 24, 2016   ❤️ 1
    同好奇,热部署咋搞……?是不是不用重新编译自动重新部署?
    YzSama
        2
    YzSama  
       Mar 24, 2016 via iPhone   ❤️ 1
    目前还在使用 idea14 。。热部署装好插件后,不是有两个 jr 按钮么?点击就是热部署了
    letitbesqzr
        3
    letitbesqzr  
       Mar 24, 2016   ❤️ 2
    直接点 jrebel 的启动不就可以了?

    @skyadmin jrebel 的原理是监控 class 目录的修改,一有修改就重载,比如改了 spring mvc 的 controller 不光会重载 还会自动调用去重扫 url 。支持的框架还是比较多。平时几乎都不重启
    YzSama
        4
    YzSama  
       Mar 24, 2016 via iPhone   ❤️ 1
    @skyadmin 你修改了 java 文件后,会自动重新编译修改的 java 文件为 class 。以至于不需要重新反覆重启编译项目所有文件
    xcaspar
        5
    xcaspar  
       Mar 24, 2016   ❤️ 1
    使用 JRebel 启动项目,更改代码后,编译项目即可,就会自动热部署。
    xiaofanz
        6
    xiaofanz  
    OP
       Mar 24, 2016
    @YzSama 确实有两个 jr 按钮,但是先需要添加一个 run/debug configuration, 请问这里面怎么配置呢?
    xiaofanz
        7
    xiaofanz  
    OP
       Mar 24, 2016
    @letitbesqzr jr 启动需要先添加一个 run/debug configuration, 请问这里面怎么配置呢?
    xiaofanz
        8
    xiaofanz  
    OP
       Mar 24, 2016
    @xcaspar jr 启动需要先添加一个 run/debug configuration, 请问这里面怎么配置呢?
    YzSama
        9
    YzSama  
       Mar 24, 2016 via iPhone
    @xiaofanz 我没用过 jetty ,我使用的是 tomcat 。我的部署方式和 eclipse 上差不多。。只是启动方式用 jr
    xiaofanz
        10
    xiaofanz  
    OP
       Mar 24, 2016
    @YzSama 恩,我以前也是用的 tomcat+jrebel 实现热部署,但是现在项目迁移到 maven 了,所以不知道怎么弄了,请问你使用的是 maven 吗?
    sorcerer
        11
    sorcerer  
       Mar 24, 2016 via iPhone
    官网上有说的,直接右键创建一个 jrebel 配置文件,然后就会自动在 resource 目录生成一个 jrebel.xml ……那个文件有 class 目录和 webapp 目录配置,根据你的实际情况修改就行了
    YzSama
        12
    YzSama  
       Mar 24, 2016
    @xiaofanz http://www.youmeek.com/intellij-idea-part-xviii-maven/
    你可以上这个网址看看。。我没使用 maven 部署项目,以前有用过。具体的配置应该不难。仔细琢磨下
    domty
        13
    domty  
       Mar 24, 2016
    我以前看到的是在 jetty 插件的配置文件里加信息,编写完 Java 代码快捷键重新编译,现在有更好的办法吗。
    低配置电脑重启次 jetty 要 70-90s ,太慢了。
    xiaofanz
        14
    xiaofanz  
    OP
       Mar 24, 2016
    @sorcerer rebel 文件 已经创建好了,但是这个 run/debug configuration 里面应该怎么配置呢?
    Suclogger
        15
    Suclogger  
       Mar 24, 2016
    @domty 我现在是停 jetty,mvn clean package -Dmaven.test.skip,再启 jetty,至少需要 5 分钟..太烦了..希望看到更好的方法
    crytis
        16
    crytis  
       Mar 24, 2016 via iPhone
    点击 build 菜单的 make project 就能重新加载,不用重启
    pelloz
        17
    pelloz  
       Mar 24, 2016
    除了想办法热部署以外,你应该写单元测试,这样就不用来回启动浪费时间了。
    ted05
        18
    ted05  
       Mar 24, 2016
    在 edit configurations 的 vm options 加上-noverify -javaagent:D:/Java/jrebel/jrebel.jar
    然后就可以用了。
    rannnn
        19
    rannnn  
       Mar 24, 2016
    难道不是原来怎么启动的 jrebel 就怎么启动么。。 0 配置啊
    sinsin
        20
    sinsin  
       Mar 24, 2016
    Suclogger
        21
    Suclogger  
       Mar 24, 2016
    有好办法了吗
    teemoer
        22
    teemoer  
       May 29, 2016
    @letitbesqzr 我擦 老大 我居然 半夜逛 V2EX 发现你了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2994 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 74ms · UTC 14:56 · PVG 22:56 · LAX 07:56 · JFK 10:56
    ♥ Do have faith in what you're doing.