xiaofanz
V2EX  ›  Java

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

  •  1
     
  •   xiaofanz · Mar 24, 2016 · 6319 views
    This topic created in 3882 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
    skyadmin
    Mar 24, 2016❤️1
    1
    同好奇,热部署咋搞……?是不是不用重新编译自动重新部署?
    YzSama
    YzSama
    Mar 24, 2016 via iPhone❤️1
    2
    目前还在使用 idea14 。。热部署装好插件后,不是有两个 jr 按钮么?点击就是热部署了
    letitbesqzr
    letitbesqzr
    Mar 24, 2016❤️2
    3
    直接点 jrebel 的启动不就可以了?

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