当前位置:编程学习 > html/css >>

Jetty与Maven集成

在项目中为了方便起见需要把服务器集成到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> 
                 &nbs

补充:web前端 , HTML 5 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,