2012-04-27 116 views
4

类似于问题Jetty startup delay Jetty 8.1.2的启动时间随着WEB-INF/lib目录中相关性的增加而增加。 (20MB〜60至90秒)Jetty 8.1.2启动延迟

带调试启用(-Dorg.eclipse.jetty.LEVEL = DEBUG,也看到此答案Enable Jetty DEBUG)大量出现下面的行中输出:

2012-04-27 11:13:38.095:DBUG:oeju.Scanner:scanned [/home/.../workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmpX/webapps]: {} 

回答

8

这是自从Servlet-API 2.5开始寻找所有类和Jars中与Servlet相关的Annotations以来的正常流程。通常情况下,这可能避免与在web.xml中的“元数据完整”选项:

<web-app metadata-complete="true" ...> 

在码头8.1.2这是由AnntionConfiguration类,但在扫描过程中,由于认识到无论如何启动发生。这是Jetty 8.1.2的已知ISSUE Jetty 8.1.2 scans all classes on classpath if there is >= 1xServletContainerInitializer with HandlesTypes on the classpath, regardless of metadata-complete="true"

解决方法是使用模式限制将包含在扫描过程中的JAR文件。例如。在Eclipse中,您可以将以下代码片段添加到“/home/.../workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmpX/contexts/appname”中的“jetty-context.xml”。 xml“文件:

<Call name="setAttribute"> 
    <Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg> 
    <Arg>.*/.*myPrefixedJarToScan1-[^/]\.jar$|.*/.*myPrefixedJarToScan2-[^/]\.jar$</Arg> 
</Call>