2012-04-27 115 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>