CommandLineRunner VS SmartLifecycle

CommandLineRunner VS SmartLifecycle

使用 @PostConstruct 并自动装配 MessageChannel 问题,我找到了解决方案

是否也可以使用 CommandLineRunner

在完全初始化上下文后开始使用 MessageChannel rabbitMQ 的最佳方式是什么?

Spring Boot 的CommandLineRunner(或ApplicationRunner)没问题。

SmartLifecycle 可用于任何 Spring 应用程序,而不仅仅是启动应用程序。