簡體   English   中英

限制maven插件中的jetty掃描

[英]limit jetty scanning in maven plugin

我在使用eclipse中的maven jetty插件快速啟動webapp時遇到了問題。 我正在使用碼頭:跑步目標。

打開日志記錄后,問題似乎是jetty掃描我的webapp中的所有jar文件以進行Web應用程序配置。 僅僅包括對jersey-media-moxy的依賴導致jetty在其啟動時間增加48秒。

如何在jetty-maven-plugin中限制此掃描? 我發現由於掃描導致Jetty啟動延遲,但在我進行一些外部jetty配置之前,包括這是maven配置,我想確保沒有更簡單的選擇。

http://eclipse.org/jetty/documentation/current/quickstart-webapp.html看起來很有希望,但我不確定如何繼續(因為這也沒有提到maven插件)。

我的pom.xml文件包含在下面:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.my-app</groupId>
    <artifactId>my-app</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>my-app</name>

    <build>
        <finalName>my-app</finalName>
        <plugins>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.2.9.v20150224</version>
                <configuration>
                    <war>${project.basedir}/target/my-app.war</war>
                    <stopPort>8088</stopPort>
                    <stopKey>foo</stopKey>
                    <stopWait>10</stopWait>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <inherited>true</inherited>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.glassfish.jersey</groupId>
                <artifactId>jersey-bom</artifactId>
                <version>${jersey.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <!-- artifactId>jersey-container-servlet-core</artifactId -->
            <!-- use the following artifactId if you don't need servlet 2.x compatibility -->
            <artifactId>jersey-container-servlet</artifactId>
        </dependency>
        <!-- uncomment this to get JSON support -->
        <!--  -->
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-moxy</artifactId>
        </dependency>
        <!-- -->
    </dependencies>
    <properties>
        <jersey.version>2.16</jersey.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

這是我用於我的項目,只是從maven pom.xml文件加速Jetty啟動(不需要外部配置):

        <plugin>  
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <configuration>
                <webApp>

                    <!-- no need to scan anything as we're using servlet 2.5 and moreover, we're not using ServletContainerInitializer(s) -->
                    <!-- for more relevant information regarding scanning of classes refer to https://java.net/jira/browse/SERVLET_SPEC-36 -->
                    <webInfIncludeJarPattern>^$</webInfIncludeJarPattern>
                    <containerIncludeJarPattern>^$</containerIncludeJarPattern>
                    <!--<webInfIncludeJarPattern>.*/spring-[^/]*\.jar$|.*/.*jsp-api-[^/]\.jar$|./.*jsp-[^/]\.jar$|./.*taglibs[^/]*\.jar$</webInfIncludeJarPattern>-->
                </webApp>
            </configuration>
        </plugin>

使用您選擇的任何正則表達式(如果您使用的是servlet初始值設定項)。 請注意, ^$排除了所有內容。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM