IDEA 热部署(JRebel插件方式)

转载链接:https://www.jianshu.com/p/44ab73d6e5af

1. IDEA开启项目自动编译

File --> Settings --> Build,Execut, Deployment --> Compiler 勾选中左侧的Build Project automatically

2. IDEA开启项目运行时自动make

Ctrl + Shift + A 搜索命令:registry --> 勾选 compiler.automake.allow.when.app.running

3. 下载 JRebel:

链接:https://pan.baidu.com/s/1t7VvCxTwmv3UyXL-AQmXrA 密码:pm6i

4. 安装 JRebel

Ctrl + Alt +S ,打开 Plugins 选择 Install plugin from disk,选择下载好的 JRebel-6.4.3.zip 压缩包(不用解压),JRebel for Intellij 勾选中,点击ApplyOK,重启 IDEA 即可。

手动安装 JRebel

5. 使用 JRebel

JRebel 仅限 Debug 模式下使用,选择第二个 Debug 按钮即可

JRebel Debug模式下使用


6. 当一个项目使用maven多模块开发时通过上面的配置, 只能自动加载webapp所在的模块, 若想改动其他模块的代码也要自动加载, 需在项目的根(父)pom.xml文件中加入下面的配置:

<build>  <-- 只需要复制两个 plugin 标签及里面的内容即可,buildplugins 标签是为了更容易理解两个 plugin 标签的放置位置 -->
    <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.zeroturnaround</groupId>
                    <artifactId>jrebel-maven-plugin</artifactId>
                    <version>1.1.5</version>
                    <configuration>
                        <addResourcesDirToRebelXml>true</addResourcesDirToRebelXml>
                        <alwaysGenerate>true</alwaysGenerate>
                        <showGenerated>true</showGenerated>
                    </configuration>
                    <executions>
                        <execution>
                            <id>generate-rebel-xml</id>
                            <phase>process-resources</phase>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
    </plugins>
</build>

将两个 plugin 标签的内容复制到pom.xml文件后,右键点击pom.xml文件,选择maven --> ReImport(首先要确保该项目是maven项目),maven会自动下载所需的文件(或者使用maven命令:mvn JRebel:generate

猜你喜欢

转载自blog.csdn.net/u012279312/article/details/80484311
今日推荐