我有以下配置:
@Configuration
@ComponentScan("com.xyz.svc")
public class SvcConfig {
@Autowired private Filter filter1;
@Autowired private Filter filter2;
@Autowired private Filter filter3;
@Bean
public List<Filter> filters() {
// Filters are added in the desired order of execution
return ImmutableList.of(
filter1,
filter2,
filter3);
}
}
当leadFilters()
方法运行时,它所依赖的所有组件(即filter1
,,filter2
)filter3
都为空。基本上,这些组件都是通过@ComponentScan
. 问题是leadFilters()
方法在之前执行@ComponentScan
。
我该如何进行这项工作?