jarファイルを共有するフィルタプロジェクトから、Springでスキャンしての定義名がのBeanを作成するクラスを提供します。たとえば、次のように続いて
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 {
// ...
}
configure the app to scan Beanを作成するcom.me.common.interceptorsパッケージ。コードが瓶に入っていても問題ありません。
アプリ内では、これらのBeanを名前で自動割り当てすることができます。registered as usual。
@Autowired
@Qualifier(InterceptorConfig .FILTER_BEAN_1)
private HandlerInterceptor interceptor1;
@Autowired
@Qualifier(InterceptorConfig .FILTER_BEAN_2)
private HandlerInterceptor interceptor2;