当前位置: 首页 > 工具软件 > io.spider > 使用案例 >

springboot启动报java.io.FileNotFoundException:问题解决

严稳
2023-12-01
2020-05-29 16:13:14.844  INFO 2896 --- [           main] com.baizhi.yxh.YingxueYxhApplication     : Starting YingxueYxhApplication on DESKTOP-NMOCS9G with PID 2896 (G:\ideaWorkSpace\yingxue_yxh\target\classes started by job in G:\ideaWorkSpace\yingxue_yxh)
2020-05-29 16:13:14.860  INFO 2896 --- [           main] com.baizhi.yxh.YingxueYxhApplication     : No active profile set, falling back to default profiles: default
2020-05-29 16:13:15.969  WARN 2896 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : Skipping MapperFactoryBean with name 'adminDao' and 'com.baizhi.yxh.dao.AdminDao' mapperInterface. Bean already defined with the same name!
2020-05-29 16:13:15.969  WARN 2896 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : Skipping MapperFactoryBean with name 'categoryMapper' and 'com.baizhi.yxh.dao.CategoryMapper' mapperInterface. Bean already defined with the same name!
2020-05-29 16:13:15.969  WARN 2896 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : Skipping MapperFactoryBean with name 'userMapper' and 'com.baizhi.yxh.dao.UserMapper' mapperInterface. Bean already defined with the same name!
2020-05-29 16:13:15.969  WARN 2896 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : Skipping MapperFactoryBean with name 'videoMapper' and 'com.baizhi.yxh.dao.VideoMapper' mapperInterface. Bean already defined with the same name!
2020-05-29 16:13:15.969  WARN 2896 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in '[com.baizhi.yxh.dao]' package. Please check your configuration.
2020-05-29 16:13:16.125  WARN 2896 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in '[com.baizhi.yxh]' package. Please check your configuration.
2020-05-29 16:13:17.032  INFO 2896 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8181 (http)
2020-05-29 16:13:17.094  INFO 2896 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-05-29 16:13:17.094  INFO 2896 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.21]
2020-05-29 16:13:17.704  WARN 2896 --- [           main] o.a.tomcat.util.scan.StandardJarScanner  : Failed to scan [file:/C:/Users/job/.m2/repository/org/bytedeco/javacv/0.8/javacpp.jar] from classloader hierarchy

java.io.FileNotFoundException: C:\Users\job\.m2\repository\org\bytedeco\javacv\0.8\javacpp.jar (系统找不到指定的文件。)
	at java.util.zip.ZipFile.open(Native Method) ~[na:1.8.0_121]
	at java.util.zip.ZipFile.<init>(ZipFile.java:219) ~[na:1.8.0_121]
	at java.util.zip.ZipFile.<init>(ZipFile.java:149) ~[na:1.8.0_121]
	at java.util.jar.JarFile.<init>(JarFile.java:166) ~[na:1.8.0_121]
	at java.util.jar.JarFile.<init>(JarFile.java:130) ~[na:1.8.0_121]
	at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:176) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:65) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:49) ~[tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:374) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.tomcat.util.scan.StandardJarScanner.processURLs(StandardJarScanner.java:309) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.tomcat.util.scan.StandardJarScanner.doScanClassPath(StandardJarScanner.java:266) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:229) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:262) [tomcat-embed-jasper-9.0.21.jar:9.0.21]
	at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:104) [tomcat-embed-jasper-9.0.21.jar:9.0.21]
	at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:83) [tomcat-embed-jasper-9.0.21.jar:9.0.21]
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5132) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_121]
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) [na:1.8.0_121]
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_121]
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) [na:1.8.0_121]
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.apache.catalina.startup.Tomcat.start(Tomcat.java:456) [tomcat-embed-core-9.0.21.jar:9.0.21]
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:105) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:414) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:178) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) [spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at com.baizhi.yxh.YingxueYxhApplication.main(YingxueYxhApplication.java:13) [classes/:na]

2020-05-29 16:13:17.704  WARN 2896 --- [           main] o.a.tomcat.util.scan.StandardJarScanner  : Failed to scan [file:/C:/Users/job/.m2/repository/org/bytedeco/javacv/0.8/opencv.jar] from classloader hierarchy

问题描述

springboot项目启动的时候报错如上所示的警告,虽然不影响项目的正常运行,但是对于一个程序员来说看到如此,如不能解决是在是寝食难安。

这里省略一万个字

解决过程

1,由于项目并未用到这几个jar包(否则项目也不能成功运行),考虑将这几个子包通过pom文件过滤出去,最后失败。
2,没办法只能dubug其报错位置,查找原因,苦于本人技术不精,大概知道,tomcat在加载pom指定的依赖时,还会分析jar包中的classpath路径,但是还是不知怎么解决,于是只能问老师了,百度(并非广告),终于找到解决方案

解决办法

原来已经有大神分析并解决了,由衷 的佩服,问题原因如下:
其实问题就是出Manifest文件中的classpath,通过分析代码我们知道tomcat除了加载了我们maven管理的jar包之外,还会对jar中的manifest文件进行分析,如果其中存在classpath,他会将其中的内容也添加jar包依赖中,并对这些jar包进行加载。

知道原因自然就能解决,将自动解析关掉就好了

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

另外附上这位大哥的博客
链接:https://www.jianshu.com/p/7ed2eaffbc18

 类似资料: