I solved this problem by removing the @Resource annotations from the Java configuration file:
public class UserBackgroundProcessorConfiguration implements AsyncConfigurer {
@Bean(name="backgroundProcessor")
public BackgroundProcessor getBackgroundProcessor() {
BackgroundProcessor backgroundProcess = new BackgroundProcessor();
return backgroundProcess;
}
@Override
@Bean(name="executor")
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(10);
executor.setMaxPoolSize(40);
executor.setQueueCapacity(25);
executor.setThreadNamePrefix("BackgroundProcessor-");
return executor;
}
}
And then adding @Resource annotations to the BackgroundProcessor class:
public class BackgroundProcessor {
@Resource private MyBean bean1;
// 4 more
@Resource private MyBean bean6;
}
For some reason this works fine. I don't like this as much, because I would prefer my classes not have a dependency on the IOC annotations, but I'll go with this solution for now.