首页 > 代码库 > 【web.xml】报错java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
【web.xml】报错java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
今天搭建新的项目,虽然在web.xml中配置了ContextLoaderListener以及IntrospectorCleanupListener
如下:
web.xml中部分代码:
1 <!-- 监听servletContext,启动contextConfigLocation中的spring配置信息 --> 2 <listener> 3 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 4 </listener> 5 6 7 <!-- 防止spring内存溢出监听器 可用可不用--> 8 <listener> 9 <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> 10 </listener>
但是,在项目启动的时候,依旧报错:
1 严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener 2 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener 3 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285) 4 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119) 5 at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:511) 6 at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:492) 7 at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118) 8 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4676) 9 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5216) 10 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 11 at org.apache.catalina.startup.HostConfig.reload(HostConfig.java:1386) 12 at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1350) 13 at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1586) 14 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:280) 15 at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94) 16 at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1164) 17 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1388) 18 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1392) 19 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1360) 20 at java.lang.Thread.run(Unknown Source) 21 五月 15, 2017 8:44:23 下午 org.apache.catalina.core.StandardContext listenerStart 22 严重: Error configuring application listener of class org.springframework.web.util.IntrospectorCleanupListener 23 java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener 24 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285) 25 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119) 26 at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:511) 27 at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:492) 28 at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118) 29 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4676) 30 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5216) 31 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 32 at org.apache.catalina.startup.HostConfig.reload(HostConfig.java:1386) 33 at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1350) 34 at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1586) 35 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:280) 36 at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94) 37 at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1164) 38 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1388) 39 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1392) 40 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1360) 41 at java.lang.Thread.run(Unknown Source)
解决方法:
项目上,右键 properties,选择进入Deployment Assembly,
然后将Maven库的架包 也选择部署,这样项目就能读取到相关的架包,就可以正常启动而不会因为找不到 某些类
【web.xml】报错java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。