ssm框架:Error creating bean with name ‘mvcContentNegotiationManager‘:

报错信息:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘mvcContentNegotiationManager’: Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.web.accept.ContentNegotiationManagerFactoryBean] from ClassLoader [sun.misc.Launcher A p p C l a s s L o a d e r @ 18 b 4 a a c 2 ] a t 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 . a n n o t a t i o n . A u t o w i r e d A n n o t a t i o n B e a n P o s t P r o c e s s o r . d e t e r m i n e C a n d i d a t e C o n s t r u c t o r s ( A u t o w i r e d A n n o t a t i o n B e a n P o s t P r o c e s s o r . j a v a : 289 ) a t 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 A u t o w i r e C a p a b l e B e a n F a c t o r y . d e t e r m i n e C o n s t r u c t o r s F r o m B e a n P o s t P r o c e s s o r s ( A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . j a v a : 1286 ) a t 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 A u t o w i r e C a p a b l e B e a n F a c t o r y . c r e a t e B e a n I n s t a n c e ( A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . j a v a : 1201 ) a t 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 A u t o w i r e C a p a b l e B e a n F a c t o r y . d o C r e a t e B e a n ( A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . j a v a : 557 ) a t 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 A u t o w i r e C a p a b l e B e a n F a c t o r y . c r e a t e B e a n ( A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . j a v a : 517 ) a t 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 . l a m b d a AppClassLoader@18b4aac2] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:289) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1286) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1201) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda AppClassLoader@18b4aac2]atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:289)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1286)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1201)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)atorg.springframework.beans.factory.support.AbstractBeanFactory.lambdadoGetBean 0 ( A b s t r a c t B e a n F a c t o r y . j a v a : 323 ) a t 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 ) a t 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 : 321 ) a t 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 : 202 ) a t 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 : 860 ) a t 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 : 878 ) a t 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 : 550 ) a t o r g . s p r i n g f r a m e w o r k . t e s t . c o n t e x t . s u p p o r t . A b s t r a c t G e n e r i c C o n t e x t L o a d e r . l o a d C o n t e x t ( A b s t r a c t G e n e r i c C o n t e x t L o a d e r . j a v a : 128 ) a t o r g . s p r i n g f r a m e w o r k . t e s t . c o n t e x t . s u p p o r t . A b s t r a c t G e n e r i c C o n t e x t L o a d e r . l o a d C o n t e x t ( A b s t r a c t G e n e r i c C o n t e x t L o a d e r . j a v a : 60 ) a t o r g . s p r i n g f r a m e w o r k . t e s t . c o n t e x t . s u p p o r t . A b s t r a c t D e l e g a t i n g S m a r t C o n t e x t L o a d e r . d e l e g a t e L o a d i n g ( A b s t r a c t D e l e g a t i n g S m a r t C o n t e x t L o a d e r . j a v a : 275 ) a t o r g . s p r i n g f r a m e w o r k . t e s t . c o n t e x t . s u p p o r t . A b s t r a c t D e l e g a t i n g S m a r t C o n t e x t L o a d e r . l o a d C o n t e x t ( A b s t r a c t D e l e g a t i n g S m a r t C o n t e x t L o a d e r . j a v a : 243 ) a t o r g . s p r i n g f r a m e w o r k . t e s t . c o n t e x t . c a c h e . D e f a u l t C a c h e A w a r e C o n t e x t L o a d e r D e l e g a t e . l o a d C o n t e x t I n t e r n a l ( D e f a u l t C a c h e A w a r e C o n t e x t L o a d e r D e l e g a t e . j a v a : 99 ) a t o r g . s p r i n g f r a m e w o r k . t e s t . c o n t e x t . c a c h e . D e f a u l t C a c h e A w a r e C o n t e x t L o a d e r D e l e g a t e . l o a d C o n t e x t ( D e f a u l t C a c h e A w a r e C o n t e x t L o a d e r D e l e g a t e . j a v a : 124 ) . . . 24 m o r e C a u s e d b y : j a v a . l a n g . I l l e g a l S t a t e E x c e p t i o n : F a i l e d t o i n t r o s p e c t C l a s s [ o r g . s p r i n g f r a m e w o r k . w e b . a c c e p t . C o n t e n t N e g o t i a t i o n M a n a g e r F a c t o r y B e a n ] f r o m C l a s s L o a d e r [ s u n . m i s c . L a u n c h e r 0(AbstractBeanFactory.java:323) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:860) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:128) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60) at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:275) at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:243) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) ... 24 more Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.web.accept.ContentNegotiationManagerFactoryBean] from ClassLoader [sun.misc.Launcher 0(AbstractBeanFactory.java:323)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:860)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)atorg.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:128)atorg.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)atorg.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:275)atorg.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:243)atorg.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)atorg.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)...24moreCausedby:java.lang.IllegalStateException:FailedtointrospectClass[org.springframework.web.accept.ContentNegotiationManagerFactoryBean]fromClassLoader[sun.misc.LauncherAppClassLoader@18b4aac2]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481)
at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:267)
… 41 more
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463)
… 43 more
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
… 47 more

问题解决

这是使用IDEA工具的一个坑
原因:缺少servlet-api.jar包(在tomcat文件夹中->lib->servlet-api.jar)

添加该jar包add library即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小诺大人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值