@ServerEndpoint 注解无法注入问题

  • Post author:
  • Post category:其他


webSocekt注解@ServerEndpoint 加了 @Component 也无法通过 @Autowired 注入对象, 这个类比较特殊 可以在 构造方法中注入:

    private final OcsService ocsService;
    private final IImAgentService imAgentService;
    private final IImSessionService sessionService;
    private final WsProperties wsProperties;

    public ImccAgentWebsocket() {
        this.ocsService = SpringUtils.getBean("ocsService");
        this.imAgentService =  SpringUtils.getBean(IImAgentService.class);
        this.sessionService =  SpringUtils.getBean(IImSessionService.class);
        this.wsProperties =  SpringUtils.getBean(WsProperties.class);
    }



版权声明:本文为qiao_xx原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。