tags:
- maven
- jetty
- idea
- jrebel
- java
maven+jetty+idea+jrebel 實(shí)現(xiàn)項(xiàng)目熱部署
開發(fā)環(huán)境
開發(fā)過程中:
修改java或者工程文件 需要重新對(duì)工程進(jìn)行build deploy耗時(shí)太久 到無法忍受
如何實(shí)現(xiàn)一次部署之后,后面的修改全部熱部署呢?
- 使用jrebel實(shí)現(xiàn)
- web容器使用的是jetty
- 項(xiàng)目管理使用的maven
- ide使用的是idea
實(shí)現(xiàn)步驟
- 打開idea中的settings-->plugins 搜索jrebel --> browse repositories
- install 開始進(jìn)入下載 下載完成之后應(yīng)用上 并且重啟idea
- 因?yàn)閖rebel是收費(fèi)軟件 破解鏈接如下:http://blog.lanyus.com/archives/317.html
正常啟動(dòng)后的樣式:
破解工具
激活路徑
server地址:http://127.0.0.1:8888/lemon lemon為任意字符串
email: 隨意輸入
激活
- 對(duì)于需要熱部署的項(xiàng)目進(jìn)行如下操作 右擊項(xiàng)目名稱 選中jrebel生成配置文件
正確的配置文件內(nèi)容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is the JRebel configuration file. It maps the running application to your IDE workspace, enabling JRebel reloading for this project.
Refer to https://manuals.zeroturnaround.com/jrebel/standalone/config.html for more information.
-->
<application generated-by="intellij" 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:/workspaces***************/target/classes"> <!--為項(xiàng)目的編譯路徑-->
</dir>
</classpath>
<web>
<link target="/">
<dir name="C:/workspace**********src/main/webapp"><!--為項(xiàng)目的路徑-->
</dir>
</link>
</web>
</application>
- 在idea菜單欄中 選中view >tool 如下 將兩個(gè)工具欄均展示出來:
view
- 在jrebel中配置你需要熱部署的項(xiàng)目 只需配置主工程即可 base等依賴據(jù)不需勾選:
jrebel
- 配置完成之后會(huì)在啟動(dòng)腳本旁邊出現(xiàn)兩個(gè)圖標(biāo) 分別為jrebel run和jrebel debug:
[圖片上傳失敗...(image-aa19a8-1513678514508)]
- 代碼中需要將jetty自身的熱部署禁用
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.16.v20140903</version>
<configuration>
<stopKey>stop</stopKey>
<stopPort>9999</stopPort>
<scanIntervalSeconds>0</scanIntervalSeconds><!--使用jetty自身的熱部署:1 不用為0-->
<contextXml>${project.basedir}/src/main/resources/jetty-context.xml</contextXml>
<webApp>
<contextPath>/</contextPath>
</webApp>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8001</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
-
當(dāng)點(diǎn)擊jrebel debug時(shí) 啟動(dòng)log出現(xiàn)如下圖內(nèi)容則標(biāo)志著配置成功
部署 啟動(dòng)之后體驗(yàn)一下熱部署吧
針對(duì)單個(gè)文件進(jìn)行的熱部署: ctrl+shift+f9
針對(duì)修改的所有文件進(jìn)行的熱部署: ctrl+f9
執(zhí)行之前別忘記ctrl + s當(dāng)執(zhí)行上面的命令是 出現(xiàn)如下的內(nèi)容 則表示部署成功:
部署成功
log中輸出
未經(jīng)作者允許 請(qǐng)勿轉(zhuǎn)載,謝謝 :)