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
最新推荐文章于 2024-05-14 15:13:23 发布