IntelliJ + Maven + 内Jetty 实现热部署项目

时间:2022-12-11 00:45:41

热部署的好处:代码修改后,不必关闭Jetty再重新启动,Maven启动时间不太和谐IntelliJ + Maven + 内Jetty 实现热部署项目。 

环境:

IntelliJ IDEA11.1.4, 

Maven2.2.1 

Jetty8.1.5
 

 

步骤:

1,在pom.xml文件中配置jetty插件的参数:scanIntervalSeconds,我的pom.xml片断如下:

              < plugin >

                <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’ 可以重新编译整个工程。