java.lang.NoClassDefFoundError: Lorg/springframework/beans/factory/access/BeanFactoryReference;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
at org.apache.catalina.core.DefaultInstanceManager.populateAnnotationsCache(DefaultInstanceManager.java:302)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:161)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:143)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4854)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.access.BeanFactoryReference
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
... 16 more
子工程中的 pom.xml 配置文件部分配置如下:
报错原因:spring
的依赖在 spring-security
依赖的后面,所以启动时编译报错:找不到该类
解决方案:将 spring
的依赖移到 spring-security
依赖之前,再次启动web项目时正常启动
ClassNotfoundException
与 NoClassDefError
都是因为编译加载不到类导致的,但是却有本质的区别
ClassNotfoundException
是在编译时JVM加载不到类或者找不到类导致的NoClassDefError
是在运行时JVM加载不到类或者找不到类