buguge - Keep it simple,stupid

知识就是力量,但更重要的,是运用知识的能力why buguge?

导航

SpringBoot程序启动报错:FileNotFoundException:class path resource [***] cannot be opened because it does not exist

SpringBoot项目,启动程序ApiApplication。好好的一个程序,今天在启动程序时发现报错。

Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.emax.channel.webapp.ApiApplication]; nested exception is java.io.FileNotFoundException: class path resource [org/apache/ibatis/plugin/Interceptor.class] cannot be opened because it does not exist

这是个老生常谈的错误,既然是org/apache/ibatis/plugin/Interceptor.class,就是缺少apache相关jar包(或其他定义了package为org.apache.ibatis.plugin的jar包)依赖。

执行mvn:clean install了一下,发现并无卵用,问题依然存在。
同样的程序,同事电脑上可以正常启动。
那看来还是跟本地jar包依赖有关。然后,沿着这个思路,把相关jar重新install一下。发现还是没解决。
我开始把焦点放在异常堆栈上,试图从stacktrace寻找一些线索,却也吃了闭门羹,没发现什么有价值的东西。

 

2022-03-01 20:08:09.116[START] [ac75dfedd2c343548a40d8e02291fd3b] [main] INFO o.a.d.s.b.c.e.AwaitingNonWebApplicationListener:162 - [Dubbo] Current Spring Boot Application is about to shutdown...
2022-03-01 20:08:09.136[START] [ac75dfedd2c343548a40d8e02291fd3b] [main] ERROR org.springframework.boot.SpringApplication:858 - Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.emax.channel.webapp.ApiApplication]; nested exception is java.io.FileNotFoundException: class path resource [org/apache/ibatis/plugin/Interceptor.class] cannot be opened because it does not exist
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:181)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:315)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at com.emax.channel.webapp.ApiApplication.main(ApiApplication.java:32)
Caused by: java.io.FileNotFoundException: class path resource [org/apache/ibatis/plugin/Interceptor.class] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:51)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.createMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:88)
at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.getMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:75)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81)
at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:685)
at org.springframework.context.annotation.ConfigurationClassParser$SourceClass.getInterfaces(ConfigurationClassParser.java:1011)
at org.springframework.context.annotation.ConfigurationClassParser.processInterfaces(ConfigurationClassParser.java:375)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:323)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:191)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:295)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:199)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167)
... 13 common frames omitted

Process finished with exit code 1


我就把异常message里提到的 Interceptor ,去相关依赖工程里去查找。 不经意发现,自己曾经在本地测试时,添加了一个实现了Interceptor的MybatisInterceptor类。 罪魁祸首就是这个MybatisInterceptor,把它去掉就好了。不禁又想起了郭德纲于谦早年的相声《羊上树》。。

 

posted on 2022-03-01 20:42  buguge  阅读(5051)  评论(0编辑  收藏  举报