我使用的是Servlet3.0,没有任何web.xml,只是使用了。当我在eclipse中使用Run启动When应用程序时,JARScanning会花费大约40秒的时间,因为它试图在所有jars中找到HandlesTypes注释。
因此,我尝试在jetty-web.xml中设置WebInfIncludeJarPattern (我也尝试了jetty-context.xml),并将其放入deployment中描述的webapp/WEB文件夹中。我还设置了元数据-完全=“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文件。在调试输出中,我可以看到jetty-web.xml文件在完成所有JARScanning之后被解析:
产出:
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如何迫使RJR更早地拿起jetty-web.xml,并且只扫描其中指定的文件?或者在RJR中还有其他方法来指定要扫描的JARS吗?
我正在使用以下版本: Eclipse: KeplerRelease4.3构建id: 20130614-0229 RJR: 1.3.3.201301020723 Jetty: 8.1.8.v20121106
窗口: 64位
谢谢
发布于 2013-10-27 00:57:38
下面是一个使用Servlet 3.x加速Jetty 8的解决方法。
文件(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>这里,我告诉Jetty,任何以mwa-web-*开头的文件都应该扫描Servlet 3.x。
发布于 2017-07-06 10:27:19
纵观RJR源代码,我发现了一个无文档的标志rjrDisableannotation,它在所有Jetty8/9/9.3.6中显着地加快了启动时间(到目前为止,我还没有注意到任何不必要的副作用--当然,顾名思义,它不再扫描注释了)。
它可以作为"Jetty“的"Run/Debug配置”中的"VM参数“启用。
例如:
-DrjrDisableannotation=true在这里,可以参考相关的源代码:
https://stackoverflow.com/questions/18527439
复制相似问题