springboot+websocket使用报错一

在尝试使用SpringBoot整合WebSocket时遇到了启动失败的问题,具体表现为构造器中SocketIOServer类型的参数无法找到合适的bean。解决方案是注释掉MessageEventHandler类上的@Component注解,从而避免在启动时自动装配导致的错误。此问题可能涉及到SpringBoot的bean扫描和依赖注入。

APPLICATION FAILED TO START


Description:

Parameter 0 of constructor in com.socket.socketIo.MessageEventHandler required a bean of type ‘com.corundumstudio.socketio.SocketIOServer’ that could not be found.
按照正常的依赖添加,程序引入后报上面错误,查看MessageEventHandler 中的代码:

@Component
public class MessageEventHandler {
    //    @Autowired
    public static SocketIOServer socketIoServer;
    //    static ArrayList<UUID> listClient = new ArrayList<>();
    private static Vector<UUID> vectorClient = new Vector<>();//客户端缓存,线程安全
    //改为address集合
//    private static Vector<String> strings = new Vector<>();//客户端缓存,线程安全
    //    static final int limitSeconds = 60;

    @Autowired
    public MessageEventHandler(SocketIOServer socketIOServer) {
        this.socketIoServer = socketIOServer;
    }

    @OnConnect
    public void onConnect(SocketIOClient client) {
        //        #########################
        //        判空
 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值