maven web项目配置jetty热部署

上一篇maven文章讲了怎么用maven创建web项目,本次主要讲如何配置jetty来热部署项目。
首先打开pom.xml文件,在<build>结点中添加plugins,添加一个plugin:
<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>1.6</source>
	<target>1.6</target>
	<showDeprecation>true</showDeprecation>
	<showWarnings>true</showWarnings>
    </configuration>
</plugin>

这个主要是对编译的时候用的,因为默认的是1.3,所以指定java1.6。
接下来配置jetty:
<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>8.1.5.v20120716</version>
    <configuration>
    	<scanIntervalSeconds>10</scanIntervalSeconds>
    	<stopKey>foo</stopKey>
    	<stopPort>9999</stopPort>
    </configuration>
    <executions>
    	<execution>
    	    <id>start-jetty</id>
    	    <phase>pre-integration-test</phase>
    	    <goals>
    		<goal>run</goal>
    	    </goals>
    	   <configuration>  					      
                <scanIntervalSeconds>0</scanIntervalSeconds>
    		<daemon>true</daemon>
    	    </configuration>
    	</execution>
    	    <execution>
    	        <id>stop-jetty</id>
    		<phase>post-integration-test</phase>
    		<goals>
    		    <goal>stop</goal>
    		</goals>
            </execution>
    	</executions>
 </plugin>


最后在命令行敲下:mvn jetty:run
jetty开启后,你对项目的修改,会热部署到上边去,不必再重启服务来查看修改后的内容。

你可能感兴趣的:(maven,jetty,jetty plugin)