maven 插件jetty/tomcat启动 web 应用

tomcat

            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                   <configuration>
                      <path>/</path>
                      <port>8000</port>
                      <uriEncoding>UTF-8</uriEncoding>  
                      <server>tomcat7</server>
                   </configuration>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                        </execution>
                    </executions>
            </plugin>

启动方法:mvn tomcat7:run

jetty

适用于jdk1.8

<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.51.v20230217</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<httpConnector>
<port>80</port>
</httpConnector>
<webAppConfig>
<contextPath>/</contextPath>
</webAppConfig>
</configuration>
</plugin>

scanIntervalSeconds元素表示该插件扫描项目变更的时间间隔,这里配置为10秒。默认为0,表示不扫描,这样就失去了自动化热部署的功能。
connector 元素用来指定运行的端口号,属性 implementation 不可以删除,值是固定的。默认端口是8080。
启动方法:mvn jetty:run -Djetty.port=9999
启动后,可以在IDE中修改jsp、htmo、css、js甚至java类,只要不是修改类名、方法名等较大的操作,插件都能够扫描变更并更新到web容器中

posted @ 2018-07-28 21:18  zhuangrunwei  阅读(436)  评论(0编辑  收藏  举报