我是靠谱客的博主 优雅冰淇淋,最近开发中收集的这篇文章主要介绍注解方式实现springMVC产生的错误,Servlet.init() for servlet [springmvc] threw exception,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

在写springMVC的demo时,产生下面错误

HTTP Status 500 – Internal Server Error
Type Exception Report

Message Servlet.init() for servlet [springmvc] threw exception

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

javax.servlet.ServletException: Servlet.init() for servlet [springmvc] threw exception
​ org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
​ org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
​ org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)
​ org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
​ org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
​ org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
​ org.apache.coyote.AbstractProtocol C o n n e c t i o n H a n d l e r . p r o c e s s ( A b s t r a c t P r o t o c o l . j a v a : 806 ) ​ o r g . a p a c h e . t o m c a t . u t i l . n e t . N i o E n d p o i n t ConnectionHandler.process(AbstractProtocol.java:806) ​ org.apache.tomcat.util.net.NioEndpoint ConnectionHandler.process(AbstractProtocol.java:806)org.apache.tomcat.util.net.NioEndpointSocketProcessor.doRun(NioEndpoint.java:1498)
​ org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
​ java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
​ java.util.concurrent.ThreadPoolExecutor W o r k e r . r u n ( T h r e a d P o o l E x e c u t o r . j a v a : 617 ) ​ o r g . a p a c h e . t o m c a t . u t i l . t h r e a d s . T a s k T h r e a d Worker.run(ThreadPoolExecutor.java:617) ​ org.apache.tomcat.util.threads.TaskThread Worker.run(ThreadPoolExecutor.java:617)org.apache.tomcat.util.threads.TaskThreadWrappingRunnable.run(TaskThread.java:61)
​ java.lang.Thread.run(Thread.java:745)
Root Cause

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.cache.interceptor.CacheInterceptor#0’: Cannot resolve reference to bean ‘cacheManager’ while setting bean property ‘cacheManager’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘cacheManager’ available
​ org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:378)
​ org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110)
​ org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1665)
​ org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1417)
​ org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
​ org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
​ org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean 0 ( A b s t r a c t B e a n F a c t o r y . j a v a : 320 ) ​ o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . D e f a u l t S i n g l e t o n B e a n R e g i s t r y . g e t S i n g l e t o n ( D e f a u l t S i n g l e t o n B e a n R e g i s t r y . j a v a : 222 ) ​ o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t B e a n F a c t o r y . d o G e t B e a n ( A b s t r a c t B e a n F a c t o r y . j a v a : 318 ) ​ o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t B e a n F a c t o r y . g e t B e a n ( A b s t r a c t B e a n F a c t o r y . j a v a : 199 ) ​ o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . D e f a u l t L i s t a b l e B e a n F a c t o r y . p r e I n s t a n t i a t e S i n g l e t o n s ( D e f a u l t L i s t a b l e B e a n F a c t o r y . j a v a : 849 ) ​ o r g . s p r i n g f r a m e w o r k . c o n t e x t . s u p p o r t . A b s t r a c t A p p l i c a t i o n C o n t e x t . f i n i s h B e a n F a c t o r y I n i t i a l i z a t i o n ( A b s t r a c t A p p l i c a t i o n C o n t e x t . j a v a : 877 ) ​ o r g . s p r i n g f r a m e w o r k . c o n t e x t . s u p p o r t . A b s t r a c t A p p l i c a t i o n C o n t e x t . r e f r e s h ( A b s t r a c t A p p l i c a t i o n C o n t e x t . j a v a : 549 ) ​ o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . F r a m e w o r k S e r v l e t . c o n f i g u r e A n d R e f r e s h W e b A p p l i c a t i o n C o n t e x t ( F r a m e w o r k S e r v l e t . j a v a : 701 ) ​ o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . F r a m e w o r k S e r v l e t . c r e a t e W e b A p p l i c a t i o n C o n t e x t ( F r a m e w o r k S e r v l e t . j a v a : 667 ) ​ o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . F r a m e w o r k S e r v l e t . c r e a t e W e b A p p l i c a t i o n C o n t e x t ( F r a m e w o r k S e r v l e t . j a v a : 715 ) ​ o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . F r a m e w o r k S e r v l e t . i n i t W e b A p p l i c a t i o n C o n t e x t ( F r a m e w o r k S e r v l e t . j a v a : 590 ) ​ o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . F r a m e w o r k S e r v l e t . i n i t S e r v l e t B e a n ( F r a m e w o r k S e r v l e t . j a v a : 529 ) ​ o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . H t t p S e r v l e t B e a n . i n i t ( H t t p S e r v l e t B e a n . j a v a : 169 ) ​ j a v a x . s e r v l e t . G e n e r i c S e r v l e t . i n i t ( G e n e r i c S e r v l e t . j a v a : 158 ) ​ o r g . a p a c h e . c a t a l i n a . a u t h e n t i c a t o r . A u t h e n t i c a t o r B a s e . i n v o k e ( A u t h e n t i c a t o r B a s e . j a v a : 493 ) ​ o r g . a p a c h e . c a t a l i n a . v a l v e s . E r r o r R e p o r t V a l v e . i n v o k e ( E r r o r R e p o r t V a l v e . j a v a : 81 ) ​ o r g . a p a c h e . c a t a l i n a . v a l v e s . A b s t r a c t A c c e s s L o g V a l v e . i n v o k e ( A b s t r a c t A c c e s s L o g V a l v e . j a v a : 660 ) ​ o r g . a p a c h e . c a t a l i n a . c o n n e c t o r . C o y o t e A d a p t e r . s e r v i c e ( C o y o t e A d a p t e r . j a v a : 343 ) ​ o r g . a p a c h e . c o y o t e . h t t p 11. H t t p 11 P r o c e s s o r . s e r v i c e ( H t t p 11 P r o c e s s o r . j a v a : 798 ) ​ o r g . a p a c h e . c o y o t e . A b s t r a c t P r o c e s s o r L i g h t . p r o c e s s ( A b s t r a c t P r o c e s s o r L i g h t . j a v a : 66 ) ​ o r g . a p a c h e . c o y o t e . A b s t r a c t P r o t o c o l 0(AbstractBeanFactory.java:320) ​ org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ​ org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ​ org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ​ org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849) ​ org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ​ org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ​ org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:701) ​ org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:667) ​ org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:715) ​ org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:590) ​ org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:529) ​ org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:169) ​ javax.servlet.GenericServlet.init(GenericServlet.java:158) ​ org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) ​ org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) ​ org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660) ​ org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ​ org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798) ​ org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) ​ org.apache.coyote.AbstractProtocol 0(AbstractBeanFactory.java:320)org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849)org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:701)org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:667)org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:715)org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:590)org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:529)org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:169)javax.servlet.GenericServlet.init(GenericServlet.java:158)org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)org.apache.coyote.AbstractProtocolConnectionHandler.process(AbstractProtocol.java:806)
​ org.apache.tomcat.util.net.NioEndpoint S o c k e t P r o c e s s o r . d o R u n ( N i o E n d p o i n t . j a v a : 1498 ) ​ o r g . a p a c h e . t o m c a t . u t i l . n e t . S o c k e t P r o c e s s o r B a s e . r u n ( S o c k e t P r o c e s s o r B a s e . j a v a : 49 ) ​ j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r . r u n W o r k e r ( T h r e a d P o o l E x e c u t o r . j a v a : 1142 ) ​ j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r SocketProcessor.doRun(NioEndpoint.java:1498) ​ org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ​ java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ​ java.util.concurrent.ThreadPoolExecutor SocketProcessor.doRun(NioEndpoint.java:1498)org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)java.util.concurrent.ThreadPoolExecutorWorker.run(ThreadPoolExecutor.java:617)
​ org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
​ java.lang.Thread.run(Thread.java:745)
Root Cause

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘cacheManager’ available
​ org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:775)
​ org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1221)
​ org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:294)
​ org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
​ org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:367)
​ org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110)
​ org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1665)
​ org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1417)
​ org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
​ org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
​ org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean 0 ( A b s t r a c t B e a n F a c t o r y . j a v a : 320 ) ​ o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . D e f a u l t S i n g l e t o n B e a n R e g i s t r y . g e t S i n g l e t o n ( D e f a u l t S i n g l e t o n B e a n R e g i s t r y . j a v a : 222 ) ​ o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t B e a n F a c t o r y . d o G e t B e a n ( A b s t r a c t B e a n F a c t o r y . j a v a : 318 ) ​ o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t B e a n F a c t o r y . g e t B e a n ( A b s t r a c t B e a n F a c t o r y . j a v a : 199 ) ​ o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . D e f a u l t L i s t a b l e B e a n F a c t o r y . p r e I n s t a n t i a t e S i n g l e t o n s ( D e f a u l t L i s t a b l e B e a n F a c t o r y . j a v a : 849 ) ​ o r g . s p r i n g f r a m e w o r k . c o n t e x t . s u p p o r t . A b s t r a c t A p p l i c a t i o n C o n t e x t . f i n i s h B e a n F a c t o r y I n i t i a l i z a t i o n ( A b s t r a c t A p p l i c a t i o n C o n t e x t . j a v a : 877 ) ​ o r g . s p r i n g f r a m e w o r k . c o n t e x t . s u p p o r t . A b s t r a c t A p p l i c a t i o n C o n t e x t . r e f r e s h ( A b s t r a c t A p p l i c a t i o n C o n t e x t . j a v a : 549 ) ​ o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . F r a m e w o r k S e r v l e t . c o n f i g u r e A n d R e f r e s h W e b A p p l i c a t i o n C o n t e x t ( F r a m e w o r k S e r v l e t . j a v a : 701 ) ​ o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . F r a m e w o r k S e r v l e t . c r e a t e W e b A p p l i c a t i o n C o n t e x t ( F r a m e w o r k S e r v l e t . j a v a : 667 ) ​ o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . F r a m e w o r k S e r v l e t . c r e a t e W e b A p p l i c a t i o n C o n t e x t ( F r a m e w o r k S e r v l e t . j a v a : 715 ) ​ o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . F r a m e w o r k S e r v l e t . i n i t W e b A p p l i c a t i o n C o n t e x t ( F r a m e w o r k S e r v l e t . j a v a : 590 ) ​ o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . F r a m e w o r k S e r v l e t . i n i t S e r v l e t B e a n ( F r a m e w o r k S e r v l e t . j a v a : 529 ) ​ o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . H t t p S e r v l e t B e a n . i n i t ( H t t p S e r v l e t B e a n . j a v a : 169 ) ​ j a v a x . s e r v l e t . G e n e r i c S e r v l e t . i n i t ( G e n e r i c S e r v l e t . j a v a : 158 ) ​ o r g . a p a c h e . c a t a l i n a . a u t h e n t i c a t o r . A u t h e n t i c a t o r B a s e . i n v o k e ( A u t h e n t i c a t o r B a s e . j a v a : 493 ) ​ o r g . a p a c h e . c a t a l i n a . v a l v e s . E r r o r R e p o r t V a l v e . i n v o k e ( E r r o r R e p o r t V a l v e . j a v a : 81 ) ​ o r g . a p a c h e . c a t a l i n a . v a l v e s . A b s t r a c t A c c e s s L o g V a l v e . i n v o k e ( A b s t r a c t A c c e s s L o g V a l v e . j a v a : 660 ) ​ o r g . a p a c h e . c a t a l i n a . c o n n e c t o r . C o y o t e A d a p t e r . s e r v i c e ( C o y o t e A d a p t e r . j a v a : 343 ) ​ o r g . a p a c h e . c o y o t e . h t t p 11. H t t p 11 P r o c e s s o r . s e r v i c e ( H t t p 11 P r o c e s s o r . j a v a : 798 ) ​ o r g . a p a c h e . c o y o t e . A b s t r a c t P r o c e s s o r L i g h t . p r o c e s s ( A b s t r a c t P r o c e s s o r L i g h t . j a v a : 66 ) ​ o r g . a p a c h e . c o y o t e . A b s t r a c t P r o t o c o l 0(AbstractBeanFactory.java:320) ​ org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ​ org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ​ org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ​ org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849) ​ org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ​ org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ​ org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:701) ​ org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:667) ​ org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:715) ​ org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:590) ​ org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:529) ​ org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:169) ​ javax.servlet.GenericServlet.init(GenericServlet.java:158) ​ org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) ​ org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) ​ org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660) ​ org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ​ org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798) ​ org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) ​ org.apache.coyote.AbstractProtocol 0(AbstractBeanFactory.java:320)org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849)org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:701)org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:667)org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:715)org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:590)org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:529)org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:169)javax.servlet.GenericServlet.init(GenericServlet.java:158)org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)org.apache.coyote.AbstractProtocolConnectionHandler.process(AbstractProtocol.java:806)
​ org.apache.tomcat.util.net.NioEndpoint S o c k e t P r o c e s s o r . d o R u n ( N i o E n d p o i n t . j a v a : 1498 ) ​ o r g . a p a c h e . t o m c a t . u t i l . n e t . S o c k e t P r o c e s s o r B a s e . r u n ( S o c k e t P r o c e s s o r B a s e . j a v a : 49 ) ​ j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r . r u n W o r k e r ( T h r e a d P o o l E x e c u t o r . j a v a : 1142 ) ​ j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r SocketProcessor.doRun(NioEndpoint.java:1498) ​ org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ​ java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ​ java.util.concurrent.ThreadPoolExecutor SocketProcessor.doRun(NioEndpoint.java:1498)org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)java.util.concurrent.ThreadPoolExecutorWorker.run(ThreadPoolExecutor.java:617)
​ org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
​ java.lang.Thread.run(Thread.java:745)
Note The full stack trace of the root cause is available in the server logs.

错误原因

xml命名空间和xsd约束问题

修改

xml文件头中idea推荐使用如下xml头

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/cache"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache.xsd">
<!--注解方式-->
<mvc:annotation-driven />
<context:component-scan base-package="com.modest.handler" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!--<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>-->
<!--<property name="prefix" value="/jsp/"/>-->
<!--<property name="suffix" value=".jsp"/>-->
</bean>
</beans>

使用 mvc 属性时,要将cache修改成mvc,否则报如上错误

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/cache/spring-mvc.xsd">
<!--注解方式-->
<mvc:annotation-driven />
<context:component-scan base-package="com.modest.handler" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
</bean>
</beans>

最后

以上就是优雅冰淇淋为你收集整理的注解方式实现springMVC产生的错误,Servlet.init() for servlet [springmvc] threw exception的全部内容,希望文章能够帮你解决注解方式实现springMVC产生的错误,Servlet.init() for servlet [springmvc] threw exception所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(40)

评论列表共有 0 条评论

立即
投稿
返回
顶部