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-08-23 15:54:50 发布