Error creating bean with name ‘multipartResolver‘: Lookup method resolution failed; 上传文件异常
生活随笔
收集整理的這篇文章主要介紹了
Error creating bean with name ‘multipartResolver‘: Lookup method resolution failed; 上传文件异常
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
瀏覽器錯誤信息:
錯誤信息:
HTTP狀態 500 - 內部服務器錯誤 類型 異常報告消息 Servlet[springmvctest]的Servlet.init()引發異常描述 服務器遇到一個意外的情況,阻止它完成請求。例外情況javax.servlet.ServletException: Servlet[springmvctest]的Servlet.init()引發異常org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346)org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:887)org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1684)org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)java.lang.Thread.run(Thread.java:748) 根本原因。org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'multipartResolver': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.web.multipart.commons.CommonsMultipartResolver] from ClassLoader [ParallelWebappClassLoadercontext: SpringMvcDemo_war_explodeddelegate: false ----------> Parent Classloader: java.net.URLClassLoader@7d6f77cc ]org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:289)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1286)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1201)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879)org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:702)org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:668)org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:716)org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:591)org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:530)org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:170)javax.servlet.GenericServlet.init(GenericServlet.java:158)org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346)org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:887)org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1684)org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)java.lang.Thread.run(Thread.java:748) 根本原因。java.lang.IllegalStateException: Failed to introspect Class [org.springframework.web.multipart.commons.CommonsMultipartResolver] from ClassLoader [ParallelWebappClassLoadercontext: SpringMvcDemo_war_explodeddelegate: false ----------> Parent Classloader: java.net.URLClassLoader@7d6f77cc ]org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481)org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321)org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:267)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1286)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1201)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879)org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:702)org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:668)org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:716)org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:591)org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:530)org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:170)javax.servlet.GenericServlet.init(GenericServlet.java:158)org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346)org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:887)org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1684)org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)java.lang.Thread.run(Thread.java:748) 根本原因。java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactoryjava.lang.Class.getDeclaredMethods0(Native Method)java.lang.Class.privateGetDeclaredMethods(Class.java:2701)java.lang.Class.getDeclaredMethods(Class.java:1975)org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463)org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321)org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:267)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1286)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1201)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879)org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:702)org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:668)org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:716)org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:591)org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:530)org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:170)javax.servlet.GenericServlet.init(GenericServlet.java:158)org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346)org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:887)org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1684)org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)java.lang.Thread.run(Thread.java:748) 根本原因。java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactoryorg.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1364)org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1187)java.lang.Class.getDeclaredMethods0(Native Method)java.lang.Class.privateGetDeclaredMethods(Class.java:2701)java.lang.Class.getDeclaredMethods(Class.java:1975)org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463)org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321)org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:267)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1286)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1201)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879)org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:702)org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:668)org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:716)org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:591)org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:530)org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:170)javax.servlet.GenericServlet.init(GenericServlet.java:158)org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346)org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:887)org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1684)org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)java.lang.Thread.run(Thread.java:748) ):注意 主要問題的全部 stack 信息可以在 server logs 里查看Apache Tomcat/9.0.43解決方案:
來源:
這個解決方案是多方確認過得,第一是問的老師,第二是百度所得
方案:
下載:commons-fileupload-1.3.3.jar 包添加到Tomcat安裝的位置的lib文件下就可以了
理論上來說,不一定非得是1.3.3版本的,只要不是太老的?commons-fileupload jar?包就應該沒問題,自己酌情選擇
遇到問題的前提:
今天學習springmvc的上傳文件,寫完了已運行就報錯,后來自己先排查錯誤,找來找去就發現,是spring配置文件中 配置上傳下載解析器 導致報的錯
?
總結
以上是生活随笔為你收集整理的Error creating bean with name ‘multipartResolver‘: Lookup method resolution failed; 上传文件异常的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基金的涨跌是怎么来的 注意这些方面就可
- 下一篇: 程序员如何日常解决错误问题