您的位置:首页 > 其它

jrebel热部署

2017-12-24 14:02 204 查看
前言

在写项目的时候,对后端类的修改或页面的修改都需要重新启动项目来查看修改后的效果,如此反反复复,效率低且不说,作为程序员等待项目重启的心情,同是做这样事情的我们,都知道的。

使用如部署插件jrebel就可以免去这么机械的反复重启的操作了。

JRebel maps your project workspace directly to a running application. JRebel then monitors the changes you make to classes and resources – and intelligently reflects them in your application.

Jrebel官网的这段话告诉我们:Jrebel将我们的项目工作空间直接映射到正在运行的项目,并且监控着项目类和资源的变化,将这些变化反映给我们正在运行的应用。所以我们不再需要重启,项目就能感知到修改了哪些内容。

使用Jrebel需要下载Jrebel插件并且激活,使用rebel.xml配置文件来配置我们的项目。

1、JAR 的配置

jars不是作为Web项目来发布的,只是作为项目的一部分,

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd"> 
<classpath>
<dir name="C:\myWorkspace\myBusinessModule\target\classes"/>
</classpath>

</application>


2、war配置

war是一个web Application 的压缩包,其包含了 JSPs, HTML files, graphic files 等文件,所以其配置文件需要添加额外的路径。

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd"> 
<classpath>
<dir name="C:\myWorkspace\myWar\target\classes"/>
</classpath>

<web>
<link target="/">
<dir name="C:\myWorkspace\myWar\src\main\webapp"/>
</link>
<link target="/jsps/">
<dir name="C:\myWorkspace\myWar\src\main\jsps"/>
</link>
</web>

</application>


配置好文件后,我们使jrebel运行我们的项目,在需要修改的时候,只需编译修改的文件,不需要重新启动项目,就可以查看修改的效果了。

小结:

使用jrebel后的确方便了很多,项目稍微大点的话,启动所花的时间还是挺久的,所以可以省很多时间。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jrebel