Intellij插件之JRebel

环境介绍:

  Win7、JDK1.8、maven+jetty插件、SpringMVC、Intellij IDEA 2018.1.2

安装插件:

  在线安装:

    Settings --> Plugins --> Browse repositories... -->搜索栏搜索:JRebel --> 点击 Install 按钮 安装

  离线安装:

    1、从官网下载 https://zeroturnaround.com/software/jrebel/download/#!/have-license/intellij  

    2、Settings --> Plugins --> Install plugin from disk...

    ps:安装完毕后重启IDEA

激活JRebel

    上官网 https://zeroturnaround.com/software/jrebel/trial/ 注册一个号,然后就可以获取到激活码。在help->JRebel->Activation中激活JRebel

配置Maven + Jetty + JRebel

1)pom.xml文件配置jetty容器和JRebel插件。

  PS:webdefault.xml文件定位于:${mvn_repro}/org/eclipse/jetty/jetty-webapp/{version}/jetty-webapp-{version}.jar,将jar解压,找到webdefault.xml复制到项目的resource目录中,修改参数即可。

<!--jetty插件-->
      <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>9.2.10.v20150310</version>
        <configuration>
          <!--热部署扫描时间,这里值设置为0表示热部署扫描由Rebel完成-->
          <scanIntervalSeconds>0</scanIntervalSeconds>
          <webAppSourceDirectory>${project.basedir}/src/main/webapp</webAppSourceDirectory>
          <httpConnector>
            <!--启动端口-->
            <port>9999</port>
          </httpConnector>
          <stopKey>sk</stopKey>
          <stopPort>9998</stopPort>
          <scanIntervalSeconds>5</scanIntervalSeconds>
          <webApp>
            <contextPath>/</contextPath>
            <!--
              解决jetty热部署不能修改静态资源的问题,
              将webdefault.xml拷贝到src/main/resources/目录中,并修改useFileMappedBuffer参数,把值设成false
            -->
            <defaultsDescriptor>src/main/resources/webdefault.xml</defaultsDescriptor>
          </webApp>
          <!--jetty:run指定加载classes路径,配置了filters,这里就不配置了
          <classesDirectory>target/${artifactId}/WEB-INF/classes</classesDirectory>-->
        </configuration>
      </plugin>

2)将工程托管给JRebel

   打开view --> Tool Windows  --> JRebel

3)配置Maven jetty 启动项

4)Maven + Jetty + JRebel 已经配置完成,我们启动一下JRebel试试看

5)修改代码后

ps:如果修改代码后没有效果,记得要Ctrl + Shift + F9(刷新当前的文件)或者Ctrl + F9(刷新整个项目)

参考:

  【1】博客,https://my.oschina.net/kfcoschina/blog/786804

原文地址:https://www.cnblogs.com/happyflyingpig/p/10059394.html