java 如何禁用 Tomcat JARScanner

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11656596/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 05:56:02  来源:igfitidea点击:

How to disable Tomcat JARScanner

javatomcattomcat7tomcat8

提问by Gonzalo Gallotti

How:To disable Tomcat JARScanner?
Why:To stop Tomcat scan every .jar in my LIB folder.

如何:禁用 Tomcat JARScanner?
原因:停止 Tomcat 扫描我的 LIB 文件夹中的每个 .jar。

According to documentationit says that it is possible to disable it within context.xml. But it seems to not be working. (May be I am missing something) I made an exhaustive search in forums and could not find the solution.

根据文档,它说可以在 context.xml 中禁用它。但它似乎不起作用。(可能是我遗漏了什么)我在论坛中进行了详尽的搜索,但找不到解决方案。

This is in context.xml (not working yet):

这是在 context.xml (尚未工作):

<JarScanner scanClassPath="false" scanAllFiles="false" scanAllDirectories="false"></JarScanner>

Thanks in advance.

提前致谢。

回答by Lari Hotari

You should add the JarScanner element as a child of the root Context element in the context.xml file.

您应该在 context.xml 文件中添加 JarScanner 元素作为根 Context 元素的子元素。

I have this kind of META-INF/context.xml file in the war file for disabling the JarScanner:

我在用于禁用 JarScanner 的 war 文件中有这种 META-INF/context.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<Context>
    <JarScanner scanClassPath="false" scanAllFiles="false" scanAllDirectories="false"/>
</Context>

回答by Black

you can disable the JarScanner globally for user-definted patterns by opeining the file at

您可以通过在以下位置打开文件来全局禁用用户定义的模式的 JarScanner

%TOMCAT_HOME%/conf/catalina.properties

and add a filename pattern to tomcat.util.scan.StandardJarScanFilter.jarsToSkiplist. For example, if you want to disable jar scanning completely you could add:

并将文件名模式添加到tomcat.util.scan.StandardJarScanFilter.jarsToSkip列表中。例如,如果您想完全禁用 jar 扫描,您可以添加:

tomcat.util.scan.StandardJarScanFilter.jarsToSkip=\
*.jar,\

NOTE: this may of course lead to issues if you're employing JSTL, as templates won't be found by the scanner

注意:如果您使用 JSTL,这当然可能会导致问题,因为扫描仪不会找到模板