nested exception is java.lang.ClassNotFoundException: Interceptor

  1. 检查配置文件引入路径是否正确,按住CTRL 鼠标悬浮在该类并点击,是否可以进入至该类。
    nested exception is java.lang.ClassNotFoundException: Interceptor_第1张图片
  2. 检查IDE扫描配置,如下图:

nested exception is java.lang.ClassNotFoundException: Interceptor_第2张图片
注: 如果配置文件中对类的引入出现异常(字体示红),则说明项目配置存在问题。

异常描述

Exception

javax.servlet.ServletException: Servlet.init() for servlet springMVC threw exception
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
	org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
	org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1137)
	org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
	org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2575)
	org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2564)
	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.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.web.servlet.handler.SimpleUrlHandlerMapping#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.handler.MappedInterceptor#1': Cannot create inner bean 'com.huawei.demo.interceptor.LoginInterceptor#0' of type [com.huawei.demo.interceptor.LoginInterceptor] while setting constructor argument; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.huawei.demo.interceptor.LoginInterceptor] for bean with name 'com.huawei.demo.interceptor.LoginInterceptor#0' defined in class path resource [conf/spring-mvc.xml]; nested exception is java.lang.ClassNotFoundException: com.huawei.demo.interceptor.LoginInterceptor
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
	org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)

你可能感兴趣的:(技术指导)