AsyncConfigurerSupport引用的Bean未进入postProcessAfterInitialization

时间:2018-09-29 04:05:01

标签: java spring-boot

共有3个班级:

@Component
public class AsyncTestBean {
}

@Component
public class MyAsyncConfigurerSupport extends AsyncConfigurerSupport {
    @Autowired
    private AsyncTestBean test;
    @Override
    public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
        return null;
    }
}

@Service
public class InitializingService extends InstantiationAwareBeanPostProcessorAdapter {
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) {
        if (bean instanceof AsyncTestBean) {
            System.out.println("---");
        }
    }
}

运行它,我们将无法获得输出--- 但是,如果我删除了@Autowired中的MyAsyncConfigurerSupport,那就可以了。 怎么了?

0 个答案:

没有答案