Explorar el Código

修改websocket依赖注入

ssk hace 2 días
padre
commit
2d50babbca

+ 8 - 3
alien-store/src/main/java/shop/alien/store/config/WebSocketProcess.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.util.ObjectUtils;
 import shop.alien.entity.store.LifeBlacklist;
@@ -31,10 +32,14 @@ import java.util.stream.Collectors;
 @ServerEndpoint(value = "/socket/{sendId}")
 public class WebSocketProcess {
 
+    @Autowired
+    private LifeMessageMapper lifeMessageMapper;
 
-    private final LifeMessageMapper lifeMessageMapper = SpringContext.getBean(LifeMessageMapper.class);
-    private final BaseRedisService baseRedisService = SpringContext.getBean(BaseRedisService.class);
-    private final LifeBlacklistMapper lifeBlacklistMapper = SpringContext.getBean(LifeBlacklistMapper.class);
+    @Autowired
+    private BaseRedisService baseRedisService;
+
+    @Autowired
+    private LifeBlacklistMapper lifeBlacklistMapper;
 
     /*
      * 持有每个webSocket对象,以key-value存储到线程安全ConcurrentHashMap,