공유 할 항아리를 만드는 필터 프로젝트에서 잘 정의 된 이름을 사용하여 Spring에서 스캔 할 수있는 클래스를 제공하십시오. 예를 들어 :
package com.me.common.interceptors;
public class InterceptorConfig {
public static final String INTERCEPTOR_BEAN_1 = "comMeCommonInterceptorsInterceptor1";
public static final String INTERCEPTOR_BEAN_2 = "comMeCommonInterceptorsInterceptor2";
@Bean(name = INTERCEPTOR_BEAN_1)
public HandlerInterceptor getInterceptor1() {
return new Interceptor1();
}
@Bean(name = INTERCEPTOR_BEAN_1)
public HandlerInterceptor getInterceptor2() {
return new Interceptor2();
}
}
public class Interceptor1 implements HandlerInterceptor {
// ...
}
public class Interceptor2 implements HandlerInterceptor {
// ...
}
그런 다음 com.me.common.interceptors 패키지는 콩을 만들 수
configure the app to scan. 항아리에있는 코드는 중요하지 않습니다.
해당 응용 프로그램 내에서 해당 빈은 이름으로 자동 연결될 수 있으며 registered as usual입니다.
@Autowired
@Qualifier(InterceptorConfig .FILTER_BEAN_1)
private HandlerInterceptor interceptor1;
@Autowired
@Qualifier(InterceptorConfig .FILTER_BEAN_2)
private HandlerInterceptor interceptor2;