Collect from 企业网站模板

报错找不到java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextAware

ssm的maven项目启动报错信息如下:

严重: Error configuring application listener of class com.liu.listener.InitBloggerData
java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextAware
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(Unknown Source)
	at java.security.SecureClassLoader.defineClass(Unknown Source)
	at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:3118)
	at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:1340)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1827)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1701)
	at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:504)
	at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:486)
	at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:113)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4984)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1572)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1562)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextAware
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1858)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1701)
	... 19 more

四月 10, 2019 10:37:14 上午 org.apache.catalina.core.StandardContext listenerStart
严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1858)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1701)
	at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:504)
	at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:486)
	at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:113)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4984)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1572)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1562)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)


值摘取关键错误信息

java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextAware

Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContextAware

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

找出关键错误信息是最后一句(红色标注),分析原因,应该是没有正确加载spring的配置文件吧

查看web.xml

image.png

image.png

路径没有问题,那是不是jar没有加载成呢,查看本地仓库

image.png


image.png

这里也没有问题

那么明明没有问题,项目也没有报错,为啥启动tomcat会找不到该jar呢

查看tomcat

1.png

原来如此,仓库里的jar根本没有添加到tomcat的lib里面

解决方法,添加maven依赖

选中项目右键-properties


image.png

image.png

image.png

image.png

image.png

重启tomcat,启动成功。查看项目lib文件,里面已经有了所有的jar

image.png

分享按钮

分享会更快解决你的问题哦!

在此处输入答案或者评论

允许提问者通过qq联系我

点击加载更多...