idea(3)-jetty配置

方式一、采用mortbay插件:

1、pom.xml

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>8.1.15.v20140411</version>
    <configuration>
        <stopKey>stop</stopKey>
        <stopPort>9998</stopPort>
        <scanIntervalSeconds>1</scanIntervalSeconds>
        <contextXml>${project.basedir}/src/test/resources/jetty-context.xml</contextXml>
        <webApp>
            <contextPath>/${project.artifactId}</contextPath>
        </webApp>
        <connectors>
            <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                <port>9999</port>
                <maxIdleTime>60000</maxIdleTime>
            </connector>
        </connectors>
    </configuration>
</plugin>

注:对于org.eclipse.jetty.server.nio.SelectChannelConnector,即使没引入该jar包,也没影响。

 

2、jetty-context.xml

关键是在${project.basedir}/src/test/resources/目录下,创建文件:jetty-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <Call name="setAttribute">
        <Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
        <Arg>.*/.*jsp-api-[^/]\.jar$|./.*jsp-[^/]\.jar$|./.*taglibs[^/]*\.jar$</Arg>
    </Call>
</Configure>

3、右上角maven窗口【刷新】,后,

 

方式二、采用eclipse插件:

1、jetty&jdk版本

9.3----->1.8
9.2----->1.7
8------->1.6

参考:https://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html

2、pom.xml

<plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.2.26.v20180806</version>
    <configuration>
        <httpConnector>
            <port>9999</port>
        </httpConnector>
        <scanIntervalSeconds>10</scanIntervalSeconds>
        <webAppConfig>
            <contextPath>/ebc_signpdf</contextPath>
        </webAppConfig>
    </configuration>
</plugin>

我用eclipse下的jetty插件时,报错:java.lang.Exception: Timeout scanning annotations。需要每次启动时,执行

mvn jetty:run -Dorg.eclipse.jetty.annotations.maxWait=120

才能解决,但是过于麻烦,因此建议采用mortbay插件。

posted @ 2019-03-22 13:53  遥远2  阅读(723)  评论(0编辑  收藏  举报