나는 spring-mvc 애플리케이션을 개발 중이다.스프링 빈은 필터에 접근 할 수 없다.
내 필터에서 콩에 액세스 할 수 없습니다. 나는이 문제를 찾을 수 없습니다 예외
org.springframework.beans.factory.NoSuchBeanDefinitionException : No qualifying bean of type [com.abc.app.SessionValue] is defined
내가 https://stackoverflow.com/a/11709272/3898076을 던져 갔다 이하지고 있지만입니다.
나는 구성 요소 검사 항목이 포함 내 web.xml을
<servlet>
<servlet-name>myapp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring_xyz-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
그리고 spring_xyz-servlet.xml 파일에 항목 아래에 있습니다.
<context:component-scan base-package="com.abc.app" />
<context:annotation-config />
<context:spring-configured />
필터 코드 :
WebApplicationContext springContext = WebApplicationContextUtils.getWebApplicationContext(fConfig.getServletContext());
springContext.getBean(SessionValue.class);
는 구성 문제는이에 있습니까?
감사합니다.
그리고'스프링 빈으로 등록 SessionValue'입니까? –
주석을 사용하여 Component로 등록되었습니다. –
'WebApplicationContextUtils'는'ContextLoaderListener'에 의해로드 된 루트 컨텍스트를 검색합니다. 루트 컨텍스트는'DispatcherServlet'에 의해로드 된 컨텍스트에 액세스하지 않습니다. bean을 루트 컨텍스트로 이동하십시오. –