spring boot中 xalan 引入报错 系统找不到指定的文件

2023-08-11 09:17:30.913  WARN 9664 --- [  restartedMain] o.a.tomcat.util.scan.StandardJarScanner  : Failed to scan [file:/D:/softout/mavenrepo/xalan/xalan/2.7.2/serializer.jar] from classloader hierarchy

java.io.FileNotFoundException: D:\softout\mavenrepo\xalan\xalan\2.7.2\serializer.jar (系统找不到指定的文件。)
	at java.util.zip.ZipFile.open(Native Method) ~[na:1.8.0_251]
	at java.util.zip.ZipFile.(ZipFile.java:225) ~[na:1.8.0_251]
	at java.util.zip.ZipFile.(ZipFile.java:155) ~[na:1.8.0_251]
	at java.util.jar.JarFile.(JarFile.java:167) ~[na:1.8.0_251]
	at java.util.jar.JarFile.(JarFile.java:131) ~[na:1.8.0_251]
	at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:221) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.tomcat.util.scan.JarFileUrlJar.(JarFileUrlJar.java:65) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:49) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:383) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.tomcat.util.scan.StandardJarScanner.processURLs(StandardJarScanner.java:318) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.tomcat.util.scan.StandardJarScanner.doScanClassPath(StandardJarScanner.java:270) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:233) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:262) [tomcat-embed-jasper-9.0.36.jar:9.0.36]
	at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:104) [tomcat-embed-jasper-9.0.36.jar:9.0.36]
	at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:83) [tomcat-embed-jasper-9.0.36.jar:9.0.36]
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5128) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) [tomcat-embed-core-9.0.36.jar:9.0.36]

spring boot  2.2.8.RELEASE 引入 xalan会报上面的错  加入这个配置

原因 内嵌的tomcat9.0.36

tomcat在8.5 中 修改了加载jar的方式,8.5 版本会解析jar中MANIFEST.MF文件,当该文件包含class-path属性时,会把该属性对象值,解析成需要加载的jar给加载进来。

@Bean
public TomcatServletWebServerFactory tomcatFactory(){
    return new TomcatServletWebServerFactory(){
 
         @Override
         protected void postProcessContext(Context context) {
             ((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
         }
    };
}

你可能感兴趣的:(java)