嵌入式tomcat无法从类加载器heirarchy

时间:2017-06-17 16:35:04

标签: tomcat tomcat8 embedded-tomcat-8

我新尝试嵌入式tomcat版本8.0.15。将maven依赖项下载到我的项目中。

创建必要的上下文和实例.Tomcat服务器正常运行。 但我得到以下警告

Jun 17, 2017 9:50:44 PM org.apache.tomcat.util.scan.StandardJarScanner scan 
WARNING: Failed to scan  [file:/C:/Users/raghavender.n/.m2/repository/xalan/xalan/2.7.2/xercesImpl.jar] from classloader hierarchy
java.io.FileNotFoundException:C:\Users\raghavender.n\.m2\repository\xalan\xalan\2.7.2\xercesImpl.jar (The system cannot find the file specified)
WARNING: Failed to scan [file:/C:/Users/raghavender.n/.m2/repository/xalan/xalan/2.7.2/xml-apis.jar] from classloader hierarchy
java.io.FileNotFoundException: C:\Users\raghavender.n\.m2\repository\xalan\xalan\2.7.2\xml-apis.jar (The system cannot find the file specified)

<!-- https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-core -->
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-core</artifactId>
        <version>8.5.15</version>
    </dependency>

如何禁用/避免嵌入式tomcat jar中的警告?

3 个答案:

答案 0 :(得分:2)

不要认为 xml-apis.jar tomcat-embed-core 所需的依赖关系,如dependency hierachy所示。

对于您的错误,请确保 xml-apis.jar 的范围不是&#34; 提供&#34;,删除 C下的所有文件:/Users/raghavender.n/.m2/repository/xalan/xalan / 并执行&#34; mvn clean install &#34;然后检查 xml-apis.jar 是否存在。

对于没有Spring Boot的嵌入式Tomcat 的Spring Web应用程序,您可以参考this post

答案 1 :(得分:2)

你可以添加 server.tomcat.additional-tld-skip-patterns=*.jar application.properties文件或 server: tomcat: additional-tld-skip-patterns: '*.jar' application.yml档案中。

参考:The Jar Scanner ComponentThe official reply

答案 2 :(得分:0)

要解决此问题,请在catalina.properties文件中添加以下行:

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