2013-08-30 39 views
1

我正在使用Servlet 3.0,而沒有使用Spring WebApplicationInitializer的任何web.xml。當我使用eclipse中的Run-Jetty-Run啓動Web應用程序時,JARScanning大約需要40秒,因爲它試圖在所有jar中查找HandlesTypes註釋。使用Jetty 8和Servlet 3.0運行Jetty-Run(RJR)掃描所有JAR文件忽略jetty-web.xml中的WebInfIncludeJarPattern

因此,我試圖在jetty-web.xml中設置WebInfIncludeJarPattern(我也試過jetty-context.xml),並將其放在webapp/WEB-INF文件夾中,如http://wiki.eclipse.org/Jetty/Howto/Avoid_slow_deployment中所述。我還設置了metadata-complete =「true」。 jetty-web.xml文件的內容是:

<Configure class="org.eclipse.jetty.webapp.WebAppContext"> 
    <Call name="setAttribute"> 
     <Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg> 
     <Arg>.*/.*foo-api-[^/]\.jar$|./.*bar-[^/]\.jar$|./.*wibble[^/]*\.jar$</Arg> 
    </Call> 
</Configure> 

但是,JarScanner仍然掃描所有JAR文件。在調試輸出我所看到的,畢竟JARScanning完成碼頭-web.xml文件中進行分析:

OUTPUT:

2013-08-30 09:09:52.836:DBUG:oejw.WebAppContext:preConfigure o.e.j.w.WebAppContext{/admin2,[file:/C:/....../src/main/webapp/]} with [email protected] 
...... 
2013-08-30 09:09:52.979:DBUG:oejw.WebAppContext:preConfigure o.e.j.w.WebAppContext{/admin2,[file:/C:/..../src/main/webapp/]} with [email protected] 
2013-08-30 09:09:53.076:DBUG:oejw.WebDescriptor:file:/C:/......../src/main/webapp/WEB-INF/web.xml: Calculated metadatacomplete = True with version=3.0 
2013-08-30 09:09:53.076:DBUG:oejw.WebAppContext:preConfigure o.e.j.w.WebAppContext{/admin2,[file:/C:/....../src/main/webapp/]} with [email protected] 
... <LOTS OF JARSCANNING> 
2013-08-30 09:10:36.677:DBUG:oejw.JarScanner:Search of file:/C:/......./httpclient-cache-4.1.2.jar 
2013-08-30 09:10:36.710:DBUG:oejw.WebAppContext:configure o.e.j.w.WebAppContext{/.................} with [email protected] 
2013-08-30 09:10:36.711:DBUG:oejw.JettyWebXmlConfiguration:Configuring web-jetty.xml 
2013-08-30 09:10:36.715:DBUG:oejw.JettyWebXmlConfiguration:Configure: file:/C:/......./src/main/webapp/WEB-INF/jetty-web.xml 

我怎麼能強迫RJR拿起碼頭的Web .xml更早,只掃描那裏指定的文件?或者在RJR中是否有其他方式來指定要掃描的JARS?

我使用以下版本:Eclipse的:開普勒發佈4.3版本ID:20130614-0229 RJR:1.3.3.201301020723碼頭:8.1.8.v20121106

WINDOWS:64位

謝謝

回答

6

這是一個用Servlet 3.x加速Jetty 8的解決方法。

  1. 創建一個文件(的jetty.xml)
  2. 打開RJR配置
  3. 單擊 「顯示高級選項」
  4. 附加的jetty.xml:

文件(碼頭。 xml)必須包含以下行:

<Configure id="Server" class="org.eclipse.jetty.server.Server"> 
    <Get name="handler"> 
    <Call name="setAttribute"> 
     <Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg> 
     <Arg>.*/mwa-web-.*\.jar$</Arg> 
    </Call> 
    </Get> 
</Configure> 

在這裏,我是tellin g Jetty應該掃描任何以mwa-web- *開頭的文件以獲取Servlet 3.x.

0

通過我碰到這個無證標誌rjrDisableannotation這在所有碼頭顯著加快啓動時間來到了RJR源代碼展望8/9/9.3.6(到目前爲止我還沒有發現任何不良的副作用 - 的當然如其名稱所示,它不再掃描註釋)。

它可以在「Jetty Webapp」的「運行/調試配置」中作爲「VM參數」啓用。

如:

-DrjrDisableannotation=true 

這裏參考了相關的源代碼:

https://github.com/xzer/run-jetty-run/blob/rjr1.3.4/Jetty8Support/plugin-jetty8/bootstrap/runjettyrun/Configs.java#L210-L212

+0

雖然這種聯繫可以回答這個問題,最好是在這裏有答案的關鍵部位和提供鏈接供參考。如果鏈接頁面更改,則僅鏈接答案可能會失效。 - [來自評論](/ review/low-quality-posts/16630269) –

+0

感謝您的反饋,我提供了一個更加穩定的鏈接到已標記的版本,以減少無效的機會 – cor3000