前置條件:web
1.安裝JRebel插件spring
打開的IntelliJ IDEA開發工具,並打開你本身的web工程;mvc
在工程目錄選擇 File->Setting 或者快捷鍵Ctrl+Alt+S 打開設置面板,參考圖以下:app
安裝完成後,須要重啓IntelliJ IDEA,在help->JRebel->Activation中激活JRebel(默認免費試用14天)。eclipse
2.配置Maven + Jetty +JRebelwebapp
1)pom.xml文件配置Jetty容器、JRebel插件maven
打開工程的pom.xml文件,添加以下代碼塊:工具
<build> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.3.14.v20161028</version> <configuration> <scanIntervalSeconds>0</scanIntervalSeconds> <stopKey>foo</stopKey> <stopPort>9999</stopPort> <webAppConfig> <contextPath>/</contextPath> <defaultsDescriptor>src/main/resources/webdefault.xml</defaultsDescriptor> </webAppConfig> </configuration> </plugin> </build>
解釋:
scanIntervalSeconds: 熱部署掃描時間(此處填寫0,表示熱部署掃描由JRebel完成)
webAppConfig->contextPath: 熱部署的項目名(好比<contextPath>/springmvc</contextPath>)
webAppConfig->defaultsDescriptor:解決jetty熱部署不能修改靜態資源的問題
將webdefault.xml拷貝到src/main/resources/目錄中,並修改useFileMappedBuffer參數,把值設成false開發工具
2)將工程託管給JRebelui
打開 View->Tool Windows->JRebel面板,選擇你的項目便可(勾上就能夠了),參考以下:
3)配置Maven-Jetty啓動項
新加maven啓動項,在commandline添加jetty:run便可(其餘參數如內存等,自行google)。
4)到此Jetty +JRebel 熱部署配置已經完成,點擊JRebel的啓動按鈕便可。 跑一下工程看下效果:
切記必定要記得Ctrl+Shift+F9編譯文件或者本身錄製宏指令編譯也能夠。
5)如何找到webdefault.xml文件?
PS:webdefault.xml文件定位於:${mvn_repro}/org/eclipse/jetty/jetty-webapp/{version}/jetty-webapp-{version}.jar,將jar解壓,找到webdefault.xml複製到項目的resource目錄中,修改參數便可。