Jetty 8和Servlet 3.0的Run-Jetty-Run(RJR)扫描所有JAR文件,忽略jetty-web.xml中的WebInfIncludeJarPattern

dda*_*awg 1 eclipse jetty servlet-3.0 runjettyrun

我正在使用没有任何web.xml的Servlet 3.0只使用Spring WebApplicationInitializer.当我在eclipse中使用Run-Jetty-Run启动Web应用程序时,JARScanning大约需要40秒,因为它试图在所有jar中找到HandlesTypes注释.

因此,我尝试在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>
Run Code Online (Sandbox Code Playgroud)

但是,JarScanner仍会扫描所有JAR文件.在调试输出中我可以看到,在完成所有JARScanning之后解析了jetty-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 runjettyrun.webapp.RJRWebInfConfiguration@1cdc4a5
......
2013-08-30 09:09:52.979:DBUG:oejw.WebAppContext:preConfigure o.e.j.w.WebAppContext{/admin2,[file:/C:/..../src/main/webapp/]} with org.eclipse.jetty.webapp.WebXmlConfiguration@136f39e
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 runjettyrun.webapp.RJRMetaInfoConfiguration@164de63
... <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 org.eclipse.jetty.webapp.JettyWebXmlConfiguration@803365
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
Run Code Online (Sandbox Code Playgroud)

如何强制RJR提前获取jetty-web.xml并仅扫描其中指定的文件?或者在RJR中还有其他方法来指定要扫描的JARS吗?

我使用以下版本:Eclipse:Kepler Release 4.3 Build id:20130614-0229 RJR:1.3.3.201301020723 Jetty:8.1.8.v20121106

WINDOWS:64位

谢谢

Edg*_*ina 6

这是使用Servlet 3.x加速Jetty 8的一种解决方法.

  1. 创建一个文件(jetty.xml)
  2. 打开RJR配置
  3. 点击"显示高级选项"
  4. 附加Jetty.xml:

文件(jetty.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>
Run Code Online (Sandbox Code Playgroud)

在这里,我告诉Jetty,任何以mwa-web-*开头的文件都应该扫描Servlet 3.x.