找不到bean

Posted IT的鱼

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了找不到bean相关的知识,希望对你有一定的参考价值。

implements  ApplicationListener<ContextRefreshedEvent>

      private static ApplicationContext context;


   @Override
    public void onApplicationEvent(ContextRefreshedEvent event) 
        context = event.getApplicationContext();
    

    public static Object getBean(Class beanName) 
        return context != null ? context.getBean(beanName) : null;
    

       DeviceService deviceService = (DeviceService) NettyUdpServerHandler.getBean(DeviceService.class);

以上是关于找不到bean的主要内容,如果未能解决你的问题,请参考以下文章