熱部署的好處:代碼修改后,不必關閉Jetty再重新啟動,Maven啟動時間不太和諧。
環境:
IntelliJ IDEA11.1.4,
Maven2.2.1
Jetty8.1.5
步驟:
1,在pom.xml文件中配置jetty插件的參數:scanIntervalSeconds,我的pom.xml片斷如下:
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<scanIntervalSeconds>1</scanIntervalSeconds>
<stopPort>9966</stopPort>
<stopKey>foo</stopKey>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>7777</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<webAppConfig>
<contextPath>/jsf-web</contextPath>
</webAppConfig>
</configuration>
</plugin>
2,當修改了java文件時,在IntelliJ中按:‘Ctrl+Shift+F9’ 將重新編譯該java文件,
如果修改了多個java文件,按‘Ctrl+F9’ 可以重新編譯整個工程。