IT学习联盟

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
IT学习联盟 门户 文章 HTML 5 查看内容

Jetty与Maven集成

2012-8-18 17:11| 发布者: admin| 查看: 606| 评论: 0

在项目中为了方便起见需要把服务器集成到Maven中以方便调试,

 

作为plugin集成:


[html] 
<plugin> 
    <groupId>org.mortbay.jetty</groupId> 
    <artifactId>jetty-maven-plugin</artifactId> 
    <configuration> 
        <scanIntervalSeconds>10</scanIntervalSeconds> 
        <webAppConfig> 
            <contextPath>/web</contextPath> 
            <!-- 额外的ClassPath配置,路N多的properties文件等 --> 
            <extraClasspath>properties</extraClasspath> 
        </webAppConfig> 
        <contextHandlers> 
            <!-- 子项目依赖,或者需要加多个项目到这一个jetty运行环境里面 --> 
            <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext"> 
                <war>../subweb/src/main/webapp</war> 
                <contextPath>/subweb</contextPath> 
            </contextHandler> 
        </contextHandlers> 
        <systemProperties> 
            <systemProperty> 
                <name>catalina.base</name> 
                <value>${basedir}/target</> 
            </systemProperty> 
        </systemProperties> 
        <connectors> 
            <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector"> 
                <port>8080</port> 
                <maxIdleTime>400000</maxIdleTime> 
            </connector> 
        </connectors> 
    </configuration> 
</plugin> 
直接在项目下运行mvn jetty:run

作为Maven参数集成:

[html] 
<profiles> 
    <profile> 
        <id>run-jetty</id> 
        <build> 
            <plugins> 
                <plugin> 
                     <groupId>org.mortbay.jetty</groupId> 
                     <artifactId>jetty-maven-plugin</artifactId> 
                     <configuration> 
                         <scanIntervalSeconds>10</scanIntervalSeconds> 
                         <webAppConfig> 
                             <contextPath>/web</contextPath> 
                             <extraClasspath>properties</extraClasspath> 
                         </webAppConfig> 
                         <contextHandlers> 
                             <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext"> 
                                 <war>../subweb/src/main/webapp</war> 
                                 <contextPath>/subweb</contextPath> 
                             </contextHandler> 
                        </contextHandlers> 
                        <systemProperties> 
                            <systemProperty> 
                                <name>catalina.base</name> 
                                <value>${basedir}/target</> 
                            </systemProperty> 
                        </systemProperties> 
                        <connectors> 
                            <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector"> 
                               <port>8080</port> 
                               <maxIdleTime>400000</maxIdleTime> 
                           </connector> 
                        </connectors> 
                    </configuration> 
                </plugin> 
            </plugins> 
        </build> 
    <profile> 
<profiles> www.2cto.com

项目下运行 mvn -DskipTests=true clean test -Prun-jetty

http://www.devhup.com/?p=140

Archiver|IT学习联盟| 网站地图

Powered by Discuz! X2.5© 2001-2010 世界学习室 大伟制作

GMT+8, 2018-10-22 20:25 , Processed in 0.102036 second(s), 12 queries .