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

Java 找不到在ServletContext中定义的名称为XXX的bean的类XXX,java,spring,spring-mvc,Java,Spring,Spring Mvc,我正在编写一个Spring MVC,遇到以下错误: 18:34:44999警告 [org.springframework.web.context.support.XmlWebApplicationContext] (MSC服务线程1-1)上下文期间遇到异常 初始化-取消刷新尝试: org.springframework.beans.factory.BeanCreationException:错误 创建名为的bean “org.springframework.web.servlet.mvc.ann

我正在编写一个Spring MVC,遇到以下错误:

18:34:44999警告 [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.CannotLoadBeanClasseException:无法 为名为的bean查找类[com.icumed.beans.RequestInterfaceImpl] ServletContext资源中定义的“scopedTarget.requestscope” [/WEB-INF/FetchDevice servlet.xml];嵌套异常是 java.lang.ClassNotFoundException: 来自[模块]的com.icumed.beans.RequestInterfaceImpl 来自服务模块的“deployment.6.BeanScopingRequestSession.war:main” 加载器]相关原因: org.springframework.beans.factory.CannotLoadBeanClasseException:无法 为名为的bean查找类[com.icumed.beans.RequestInterfaceImpl] ServletContext资源中定义的“scopedTarget.requestscope” [/WEB-INF/FetchDevice servlet.xml];嵌套异常是 java.lang.ClassNotFoundException: 来自[模块]的com.icumed.beans.RequestInterfaceImpl 来自服务模块的“deployment.6.BeanScopingRequestSession.war:main” 加载器]相关原因: org.springframework.beans.factory.CannotLoadBeanClasseException:无法 查找名为的bean的类[com.icumed.beans.SessionInterfaceImpl] ServletContext资源中定义的“scopedTarget.sessionscope” [/WEB-INF/FetchDevice servlet.xml];嵌套异常是 java.lang.ClassNotFoundException: com.icumed.beans.SessionInterfaceImpl from[模块] 来自服务模块的“deployment.6.BeanScopingRequestSession.war:main” 装载机]

我的目录结构:

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>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   xmlns:aop="http://www.springframework.org/schema/aop"
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-3.0.xsd
   http://www.springframework.org/schema/aop
   http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
   http://www.springframework.org/schema/mvc
   http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
 <mvc:annotation-driven />

<bean
  class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="prefix" value="/WEB-INF/jsp/" />
  <property name="suffix" value=".jsp" />
</bean>

<context:component-scan base-package="com.icumed.beans" />
<context:annotation-config />

<bean id="requestscope" class="com.icumed.beans.RequestInterfaceImpl" scope="request">
  <constructor-arg value="Device1"/>
   <aop:scoped-proxy proxy-target-class="false" />
</bean>

<bean id="sessionscope" class="com.icumed.beans.SessionInterfaceImpl" scope="session">
  <constructor-arg value="Device2"/>
   <aop:scoped-proxy proxy-target-class="false" />
</bean>
</beans>
第一: 您可以更改过滤器。有时候它需要这些

<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>      //filter path
</filter-mapping>

或者您可以设置代理目标class=“true”。我认为这是错误的,因为代理

:这有帮助。如您所述,我们已经设置了代理目标class=“true”。另外,在TestController中进行自动连接时,我使用限定符指向适当的beanId
<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>      //filter path
</filter-mapping>
@Autowired(required=true)
private RequestInterface requestInterface;   // use its interface, not impl