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

来源:互联网 发布:乌云镜像 知乎 编辑:程序博客网 时间:2024/06/05 11:44

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

环境:

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

0 0
原创粉丝点击