首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行- Jetty (RJR)使用jetty 8和Servlet3.0扫描JAR文件,忽略jettyweb.xml中的WebInfIncludeJarPattern

运行- Jetty (RJR)使用jetty 8和Servlet3.0扫描JAR文件,忽略jettyweb.xml中的WebInfIncludeJarPattern
EN

Stack Overflow用户
提问于 2013-08-30 07:36:57
回答 2查看 1.8K关注 0票数 1

我使用的是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文件的内容是:

代码语言:javascript
复制
<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之后被解析:

产出:

代码语言:javascript
复制
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位

谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-10-27 00:57:38

下面是一个使用Servlet 3.x加速Jetty 8的解决方法。

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

文件(jetty.xml)必须有以下几行:

代码语言:javascript
复制
<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。

票数 6
EN

Stack Overflow用户

发布于 2017-07-06 10:27:19

纵观RJR源代码,我发现了一个无文档的标志rjrDisableannotation,它在所有Jetty8/9/9.3.6中显着地加快了启动时间(到目前为止,我还没有注意到任何不必要的副作用--当然,顾名思义,它不再扫描注释了)。

它可以作为"Jetty“的"Run/Debug配置”中的"VM参数“启用。

例如:

代码语言:javascript
复制
-DrjrDisableannotation=true

在这里,可以参考相关的源代码:

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18527439

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档