We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我看了源码,ServerEndpointExporter 实现自SmartInitializingSingleton这个后置处理器,该处理器是在所有的Bean都初始化完成后,再执行的,如果不用@component修饰,只要其它Bean注入都会报这个异常。
如果搭配@component一起使用,就不会有该问题,我看大佬本身想剔除对@component的依赖,只需要单独使用@serverendpoint注解。所以提了该issue。
The text was updated successfully, but these errors were encountered:
我尝试的改了一下这个问题,ServerEndpointExporter 再实现一个后置处理器接口 BeanDefinitionRegistryPostProcessor,registerEndpoints中的scanPackage方法放到postProcessBeanFactory方法中执行,让扫描提前执行,就不会再报异常 `public class ServerEndpointExporter extends ApplicationObjectSupport implements SmartInitializingSingleton, BeanFactoryAware, ResourceLoaderAware,BeanDefinitionRegistryPostProcessor {
BeanDefinitionRegistryPostProcessor
registerEndpoints中的scanPackage方法
postProcessBeanFactory
@Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException { } @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException { ApplicationContext context = getApplicationContext(); scanPackage(context); } protected void registerEndpoints() { ApplicationContext context = getApplicationContext(); // scanPackage(context); String[] endpointBeanNames = context.getBeanNamesForAnnotation(ServerEndpoint.class); Set<Class<?>> endpointClasses = new LinkedHashSet<>(); for (String beanName : endpointBeanNames) { endpointClasses.add(context.getType(beanName)); } for (Class<?> endpointClass : endpointClasses) { if (ClassUtils.isCglibProxyClass(endpointClass)) { registerEndpoint(endpointClass.getSuperclass()); } else { registerEndpoint(endpointClass); } } init(); }
}`
Sorry, something went wrong.
我怎么感觉你的用法跟我的相反了,不是应该是MyWebSocket注入其他bean吗
No branches or pull requests
我看了源码,ServerEndpointExporter 实现自SmartInitializingSingleton这个后置处理器,该处理器是在所有的Bean都初始化完成后,再执行的,如果不用@component修饰,只要其它Bean注入都会报这个异常。
如果搭配@component一起使用,就不会有该问题,我看大佬本身想剔除对@component的依赖,只需要单独使用@serverendpoint注解。所以提了该issue。
The text was updated successfully, but these errors were encountered: