记录一次springboot项目启动注入失败

监听器注入实例失败   注入失败    无法注入  

    private static  RunCabinetProductService runCabinetProductService;


    private  static RocketmqLogMapper rocketmqLogMapper;

实现接口

@Configuration
public class RocketMQConsumer implements  ServletContextListener {

实现初始化方法

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        rocketmqLogMapper = WebApplicationContextUtils
            .getWebApplicationContext(servletContextEvent.getServletContext())
            .getBean(RocketmqLogMapper.class);

        runCabinetProductService = WebApplicationContextUtils
            .getWebApplicationContext(servletContextEvent.getServletContext())
            .getBean(RunCabinetProductService.class);


    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }
原文地址:https://www.cnblogs.com/qq376324789/p/15043268.html