找不到在ServletContext中定义的名称为XXX的bean的类XXX

我正在编写Spring MVC并遇到以下错误:

18:34:44,999警告[org.springframework.web.context.support.XmlWebApplicationContext](MSC服务线程1-1)上下文初始化期间遇到异常-取消刷新尝试:org.springframework.beans.factory.BeanCreationException:创建bean时出错名称为“ org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0”:Bean初始化失败;嵌套的异常是org.springframework.beans.factory.CannotLoadBeanClassException:找不到在ServletContext资源[/WEB-INF/FetchDevice-servlet.xml]中定义的名称为'scopedTarget.requestscope'的bean的类[com.icumed.beans.RequestInterfaceImpl]。 ; 嵌套的异常是java.lang.ClassNotFoundException:com.icumed.beans.RequestInterfaceImpl,来自[Module“ deployment.6.BeanScopingRequestSession.war:

我的目录结构:

http://img4.mukewang.com/60a4ec660001b90103100553.jpg

web.xml


<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

        xmlns="http://java.sun.com/xml/ns/javaee"

        xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

                            http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

        id="WebApp_ID" version="2.5">

  <display-name>ICUMED-Req-Session-scope</display-name>

  <servlet>

    <servlet-name>FetchDevice</servlet-name>

    <servlet-class>

         org.springframework.web.servlet.DispatcherServlet

      </servlet-class>

    <load-on-startup>1</load-on-startup>

  </servlet>

  <servlet-mapping>

    <servlet-name>FetchDevice</servlet-name>

    <url-pattern>/</url-pattern>

  </servlet-mapping>

  <listener>

    <listener-class>

        org.springframework.web.context.request.RequestContextListener

    </listener-class>

  </listener>

</web-app>


一只萌萌小番薯
浏览 223回答 1
1回答

Smart猫小萌

首先:您可以更改过滤器。有时它需要那些。<filter><filter-name>requestContextFilter</filter-name><filter-class>org.springframework.web.filter.RequestContextFilter</filterclass></filter><filter-mapping><filter-name>requestContextFilter</filter-name><url-pattern>/*</url-pattern>&nbsp; &nbsp; &nbsp; //filter path</filter-mapping>第二:你知道的RequestInterfaceImpl是@Autowired。它需要代理;您设置了proxy-target-class="false",因此它将使用JDK代理而不是CGLib。您可以执行以下操作:@Autowired(required=true)private RequestInterface requestInterface;&nbsp; &nbsp;// use its interface, not impl或者您可以设置proxy-target-class="true"。我认为这是错误的,因为代理!
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java