我正在使用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位
謝謝
雖然這種聯繫可以回答這個問題,最好是在這裏有答案的關鍵部位和提供鏈接供參考。如果鏈接頁面更改,則僅鏈接答案可能會失效。 - [來自評論](/ review/low-quality-posts/16630269) –
感謝您的反饋,我提供了一個更加穩定的鏈接到已標記的版本,以減少無效的機會 – cor3000