使用websocket,注入依赖service的bean为null

问题:依赖注入失败,service获取不到,提示null

这是参考代码

package com.shier.ws;import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.google.gson.Gson;
import com.shier.config.HttpSessionConfig;
import com.shier.model.domain.Chat;
import com.shier.model.domain.Team;
import com.shier.model.domain.User;
import com.shier.model.request.MessageRequest;
import com.shier.model.vo.ChatMessageVO;
import com.shier.model.vo.WebSocketVO;
import com.shier.service.ChatService;
import com.shier.service.TeamService;
import com.shier.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.io.Serializable;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;import static com.shier.constants.ChatConstant.*;
import static com.shier.constants.UserConstants.ADMIN_ROLE;
import static com.shier.constants.UserConstants.USER_LOGIN_STATE;/*** WebSocket服务*/
@Component
@Slf4j
@ServerEndpoint(value = "/websocket/{userId}/{teamId}", configurator = HttpSessionConfig.class)
public class WebSocket {/*** 保存队伍的连接信息*/private static final Map<String, ConcurrentHashMap<String, WebSocket>> ROOMS = new HashMap<>();/*** 线程安全的无序的集合*/private static final CopyOnWriteArraySet<Session> SESSIONS = new CopyOnWriteArraySet<>();/*** 会话池*/private static final Map<String, Session> SESSION_POOL = new HashMap<>(0);/*** 用户服务*/private static UserService userService;/*** 聊天服务*/private static ChatService chatService;/*** 团队服务*/private static TeamService teamService;/*** 房间在线人数*/private static int onlineCount = 0;/*** 当前信息*/private Session session;/*** http会话*/private HttpSession httpSession;/*** 上网数** @return int*/public static synchronized int getOnlineCount() {return onlineCount;}/*** 添加在线计数*/public static synchronized void addOnlineCount() {WebSocket.onlineCount++;}/*** 子在线计数*/public static synchronized void subOnlineCount() {WebSocket.onlineCount--;}/*** 集热地图服务** @param userService 用户服务*/@Resourcepublic void setHeatMapService(UserService userService) {WebSocket.userService = userService;}/*** 集热地图服务** @param chatService 聊天服务*/@Resourcepublic void setHeatMapService(ChatService chatService) {WebSocket.chatService = chatService;}/*** 集热地图服务** @param teamService 团队服务*/@Resourcepublic void setHeatMapService(TeamService teamService) {WebSocket.teamService = teamService;}/*** 队伍内群发消息** @param teamId 团队id* @param msg    消息*/public static void broadcast(String teamId, String msg) {ConcurrentHashMap<String, WebSocket> map = ROOMS.get(teamId);// keySet获取map集合key的集合  然后在遍历key即可for (String key : map.keySet()) {try {WebSocket webSocket = map.get(key);webSocket.sendMessage(msg);} catch (Exception e) {e.printStackTrace();}}}/*** 发送消息** @param message 消息* @throws IOException ioexception*/public void sendMessage(String message) throws IOException {this.session.getBasicRemote().sendText(message);}/*** 开放** @param session 会话* @param userId  用户id* @param teamId  团队id* @param config  配置*/@OnOpenpublic void onOpen(Session session, @PathParam(value = "userId") String userId, @PathParam(value = "teamId") String teamId, EndpointConfig config) {try {if (StringUtils.isBlank(userId) || "undefined".equals(userId)) {sendError(userId, "参数有误");return;}HttpSession httpSession = (HttpSession) config.getUserProperties().get(HttpSession.class.getName());User user = (User) httpSession.getAttribute(USER_LOGIN_STATE);if (user != null) {this.session = session;this.httpSession = httpSession;}if (!"NaN".equals(teamId)) {if (!ROOMS.containsKey(teamId)) {ConcurrentHashMap<String, WebSocket> room = new ConcurrentHashMap<>(0);room.put(userId, this);ROOMS.put(String.valueOf(teamId), room);// 在线数加1addOnlineCount();} else {if (!ROOMS.get(teamId).containsKey(userId)) {ROOMS.get(teamId).put(userId, this);// 在线数加1addOnlineCount();}}} else {SESSIONS.add(session);SESSION_POOL.put(userId, session);sendAllUsers();}} catch (Exception e) {e.printStackTrace();}}/*** 关闭** @param userId  用户id* @param teamId  团队id* @param session 会话*/@OnClosepublic void onClose(@PathParam("userId") String userId, @PathParam(value = "teamId") String teamId, Session session) {try {if (!"NaN".equals(teamId)) {ROOMS.get(teamId).remove(userId);if (getOnlineCount() > 0) {subOnlineCount();}} else {if (!SESSION_POOL.isEmpty()) {SESSION_POOL.remove(userId);SESSIONS.remove(session);}sendAllUsers();}} catch (Exception e) {e.printStackTrace();}}/*** 消息** @param message 消息* @param userId  用户id*/@OnMessagepublic void onMessage(String message, @PathParam("userId") String userId) {if ("PING".equals(message)) {sendOneMessage(userId, "pong");return;}MessageRequest messageRequest = new Gson().fromJson(message, MessageRequest.class);Long toId = messageRequest.getToId();Long teamId = messageRequest.getTeamId();String text = messageRequest.getText();Integer chatType = messageRequest.getChatType();User fromUser = userService.getById(userId);Team team = teamService.getById(teamId);if (chatType == PRIVATE_CHAT) {// 私聊privateChat(fromUser, toId, text, chatType);} else if (chatType == TEAM_CHAT) {// 队伍内聊天teamChat(fromUser, text, team, chatType);} else {// 群聊hallChat(fromUser, text, chatType);}}/*** 队伍聊天** @param user     用户* @param text     文本* @param team     团队* @param chatType 聊天类型*/private void teamChat(User user, String text, Team team, Integer chatType) {ChatMessageVO ChatMessageVO = new ChatMessageVO();WebSocketVO fromWebSocketVO = new WebSocketVO();BeanUtils.copyProperties(user, fromWebSocketVO);ChatMessageVO.setFormUser(fromWebSocketVO);ChatMessageVO.setText(text);ChatMessageVO.setTeamId(team.getId());ChatMessageVO.setChatType(chatType);ChatMessageVO.setCreateTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));if (user.getId() == team.getUserId() || user.getRole() == ADMIN_ROLE) {ChatMessageVO.setIsAdmin(true);}User loginUser = (User) this.httpSession.getAttribute(USER_LOGIN_STATE);if (loginUser.getId() == user.getId()) {ChatMessageVO.setIsMy(true);}String toJson = new Gson().toJson(ChatMessageVO);try {broadcast(String.valueOf(team.getId()), toJson);saveChat(user.getId(), null, text, team.getId(), chatType);chatService.deleteKey(CACHE_CHAT_TEAM, String.valueOf(team.getId()));} catch (Exception e) {throw new RuntimeException(e);}}/*** 大厅聊天** @param user     用户* @param text     文本* @param chatType 聊天类型*/private void hallChat(User user, String text, Integer chatType) {ChatMessageVO ChatMessageVO = new ChatMessageVO();WebSocketVO fromWebSocketVO = new WebSocketVO();BeanUtils.copyProperties(user, fromWebSocketVO);ChatMessageVO.setFormUser(fromWebSocketVO);ChatMessageVO.setText(text);ChatMessageVO.setChatType(chatType);ChatMessageVO.setCreateTime(DateUtil.format(new Date(), "yyyy年MM月dd日 HH:mm:ss"));if (user.getRole() == ADMIN_ROLE) {ChatMessageVO.setIsAdmin(true);}User loginUser = (User) this.httpSession.getAttribute(USER_LOGIN_STATE);if (loginUser.getId() == user.getId()) {ChatMessageVO.setIsMy(true);}String toJson = new Gson().toJson(ChatMessageVO);sendAllMessage(toJson);saveChat(user.getId(), null, text, null, chatType);chatService.deleteKey(CACHE_CHAT_HALL, String.valueOf(user.getId()));}/*** 私聊** @param user     用户* @param toId     为id* @param text     文本* @param chatType 聊天类型*/private void privateChat(User user, Long toId, String text, Integer chatType) {ChatMessageVO ChatMessageVO = chatService.chatResult(user.getId(), toId, text, chatType, DateUtil.date(System.currentTimeMillis()));User loginUser = (User) this.httpSession.getAttribute(USER_LOGIN_STATE);if (loginUser.getId() == user.getId()) {ChatMessageVO.setIsMy(true);}String toJson = new Gson().toJson(ChatMessageVO);sendOneMessage(toId.toString(), toJson);saveChat(user.getId(), toId, text, null, chatType);chatService.deleteKey(CACHE_CHAT_PRIVATE, user.getId() + "" + toId);chatService.deleteKey(CACHE_CHAT_PRIVATE, toId + "" + user.getId());}/*** 保存聊天** @param userId   用户id* @param toId     为id* @param text     文本* @param teamId   团队id* @param chatType 聊天类型*/private void saveChat(Long userId, Long toId, String text, Long teamId, Integer chatType) {
//        if (chatType == PRIVATE_CHAT) {
//            User user = userService.getById(userId);
//            Set<Long> userIds = stringJsonListToLongSet(user.getFriendIds());
//            if (!userIds.contains(toId)) {
//                sendError(String.valueOf(userId), "该用户不是你的好友");
//                return;
//            }
//        }Chat chat = new Chat();chat.setFromId(userId);chat.setText(String.valueOf(text));chat.setChatType(chatType);chat.setCreateTime(new Date());if (toId != null && toId > 0) {chat.setToId(toId);}if (teamId != null && teamId > 0) {chat.setTeamId(teamId);}chatService.save(chat);}/*** 发送失败** @param userId       用户id* @param errorMessage 错误消息*/private void sendError(String userId, String errorMessage) {JSONObject obj = new JSONObject();obj.set("error", errorMessage);sendOneMessage(userId, obj.toString());}/*** 广播消息** @param message 消息*/public void sendAllMessage(String message) {for (Session session : SESSIONS) {try {if (session.isOpen()) {synchronized (session) {session.getBasicRemote().sendText(message);}}} catch (Exception e) {e.printStackTrace();}}}/*** 发送一个消息** @param userId  用户编号* @param message 消息*/public void sendOneMessage(String userId, String message) {Session session = SESSION_POOL.get(userId);if (session != null && session.isOpen()) {try {synchronized (session) {session.getBasicRemote().sendText(message);}} catch (Exception e) {e.printStackTrace();}}}/*** 给所有用户*/public void sendAllUsers() {HashMap<String, List<WebSocketVO>> stringListHashMap = new HashMap<>(0);List<WebSocketVO> WebSocketVOs = new ArrayList<>();stringListHashMap.put("users", WebSocketVOs);for (Serializable key : SESSION_POOL.keySet()) {User user = userService.getById(key);WebSocketVO WebSocketVO = new WebSocketVO();BeanUtils.copyProperties(user, WebSocketVO);WebSocketVOs.add(WebSocketVO);}sendAllMessage(JSONUtil.toJsonStr(stringListHashMap));}
}

这是自己的代码

package com.ruoyi.webSocket;import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.room.domain.Room;
import com.ruoyi.room.service.IRoomService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;@Component
@ServerEndpoint("/module/websocket/{userId}/{roomId}")
public class WebSocketServer implements ApplicationContextAware {private static IRoomService roomService;private static final Logger log = LoggerFactory.getLogger(WebSocketServer.class);// 保存队伍的连接信息 - 新增private static final Map<String, ConcurrentHashMap<String, WebSocketServer>> ROOMS = new HashMap<>();//静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。private static AtomicInteger onlineNum = new AtomicInteger();//concurrent包的线程安全Set,用来存放每个客户端对应的WebSocketServer对象。private static ConcurrentHashMap<String, Session> sessionPools = new ConcurrentHashMap<>();// 线程安全list,用来存放 在线客户端账号public static List<String> userList = new CopyOnWriteArrayList<>();// 连接成功@OnOpenpublic void onOpen(Session session, @PathParam(value = "userId") String userId, @PathParam(value = "roomId") String roomId) {// 创建session给客户sessionPools.put(userId, session);if (!userList.contains(userId)) {addOnlineCount();userList.add(userId);}try {if (StringUtils.isBlank(userId) || "undefined".equals(userId) ||StringUtils.isBlank(roomId) || "undefined".equals(roomId)) {sendError(userId, "参数有误");return;}if (!ROOMS.containsKey(roomId)) {// 房间不存在 创建房间ConcurrentHashMap<String, WebSocketServer> room = new ConcurrentHashMap<>(0);room.put(userId, this);ROOMS.put(String.valueOf(roomId), room);} else {if (!ROOMS.get(roomId).containsKey(userId)) {// 房间存在 客户不存在 房间加入客户ROOMS.get(roomId).put(userId, this);}}log.debug("ID为【" + userId + "】的用户加入websocket!当前在线人数为:" + onlineNum);log.debug("当前在线:" + userList);} catch (Exception e) {e.printStackTrace();}}/*** 关闭连接* @param userId*/@OnClosepublic void onClose(@PathParam(value = "userId") String userId) {sessionPools.remove(userId);if (userList.contains(userId)) {userList.remove(userId);subOnlineCount();}log.debug(userId + "断开webSocket连接!当前人数为" + onlineNum);}/*** 消息监听 接收客户端消息* @param message* @throws IOException*/@OnMessagepublic void onMessage(String message) throws IOException {JSONObject jsonObject = JSONObject.parseObject(message);String userId = jsonObject.getString("userId");String roomId = jsonObject.getString("roomId");String type = jsonObject.getString("type");if (type.equals(MessageType.DETAIL.getType())) {log.debug("房间详情");try {Room room = roomService.selectRoomById(Long.parseLong(roomId));jsonObject.put("roomInfo", room);ConcurrentHashMap<String, WebSocketServer> map = ROOMS.get(roomId);// 获取玩家列表 keySet获取map集合key的集合  然后在遍历key即可for (String key : map.keySet()) {try {sendToUser(key, JSONObject.toJSONString(jsonObject));} catch (Exception e) {e.printStackTrace();}}} catch (NumberFormatException e) {System.out.println("转换错误: " + e.getMessage());}}}/*** 连接错误* @param session* @param throwable* @throws IOException*/@OnErrorpublic void onError(Session session, Throwable throwable) throws IOException {log.error("websocket连接错误!");throwable.printStackTrace();}/*** 发送消息*/public void sendMessage(Session session, String message) throws IOException, EncodeException {if (session != null) {synchronized (session) {session.getBasicRemote().sendText(message);}}}/*** 给指定用户发送信息*/public void sendToUser(String userId, String message) {Session session = sessionPools.get(userId);try {if (session != null) {sendMessage(session, message);}else {log.debug("推送用户不在线");}} catch (Exception e) {e.printStackTrace();}}public static void addOnlineCount() {onlineNum.incrementAndGet();}public static void subOnlineCount() {onlineNum.decrementAndGet();}/*** 发送失败** @param userId       用户id* @param errorMessage 错误消息*/private void sendError(String userId, String errorMessage) {JSONObject obj = new JSONObject();obj.put("error", errorMessage);sendOneMessage(userId, obj.toString());}/*** 发送一个消息** @param userId  用户编号* @param message 消息*/public void sendOneMessage(String userId, String message) {Session session = sessionPools.get(userId);if (session != null && session.isOpen()) {try {synchronized (session) {session.getBasicRemote().sendText(message);}} catch (Exception e) {e.printStackTrace();}}}
}

修改后的代码

package com.ruoyi.webSocket;import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.room.domain.Room;
import com.ruoyi.room.service.IRoomService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;@Component
@ServerEndpoint("/module/websocket/{userId}/{roomId}")
public class WebSocketServer implements ApplicationContextAware {private static ApplicationContext context;@Overridepublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException {context = applicationContext;}public static <roomService> roomService getBean(Class<roomService> beanClass) {return context.getBean(beanClass);}private static final Logger log = LoggerFactory.getLogger(WebSocketServer.class);// 保存队伍的连接信息 - 新增private static final Map<String, ConcurrentHashMap<String, WebSocketServer>> ROOMS = new HashMap<>();//静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。private static AtomicInteger onlineNum = new AtomicInteger();//concurrent包的线程安全Set,用来存放每个客户端对应的WebSocketServer对象。private static ConcurrentHashMap<String, Session> sessionPools = new ConcurrentHashMap<>();// 线程安全list,用来存放 在线客户端账号public static List<String> userList = new CopyOnWriteArrayList<>();// 连接成功@OnOpenpublic void onOpen(Session session, @PathParam(value = "userId") String userId, @PathParam(value = "roomId") String roomId) {// 创建session给客户sessionPools.put(userId, session);if (!userList.contains(userId)) {addOnlineCount();userList.add(userId);}try {if (StringUtils.isBlank(userId) || "undefined".equals(userId) ||StringUtils.isBlank(roomId) || "undefined".equals(roomId)) {sendError(userId, "参数有误");return;}if (!ROOMS.containsKey(roomId)) {// 房间不存在 创建房间ConcurrentHashMap<String, WebSocketServer> room = new ConcurrentHashMap<>(0);room.put(userId, this);ROOMS.put(String.valueOf(roomId), room);} else {if (!ROOMS.get(roomId).containsKey(userId)) {// 房间存在 客户不存在 房间加入客户ROOMS.get(roomId).put(userId, this);}}log.debug("ID为【" + userId + "】的用户加入websocket!当前在线人数为:" + onlineNum);log.debug("当前在线:" + userList);} catch (Exception e) {e.printStackTrace();}}/*** 关闭连接* @param userId*/@OnClosepublic void onClose(@PathParam(value = "userId") String userId) {sessionPools.remove(userId);if (userList.contains(userId)) {userList.remove(userId);subOnlineCount();}log.debug(userId + "断开webSocket连接!当前人数为" + onlineNum);}/*** 消息监听 接收客户端消息* @param message* @throws IOException*/@OnMessagepublic void onMessage(String message) throws IOException {JSONObject jsonObject = JSONObject.parseObject(message);String userId = jsonObject.getString("userId");String roomId = jsonObject.getString("roomId");String type = jsonObject.getString("type");if (type.equals(MessageType.DETAIL.getType())) {log.debug("房间详情");try {Room room = context.getBean(IRoomService.class).selectRoomById(Long.parseLong(roomId));jsonObject.put("roomInfo", room);ConcurrentHashMap<String, WebSocketServer> map = ROOMS.get(roomId);// 获取玩家列表 keySet获取map集合key的集合  然后在遍历key即可for (String key : map.keySet()) {try {sendToUser(key, JSONObject.toJSONString(jsonObject));} catch (Exception e) {e.printStackTrace();}}} catch (NumberFormatException e) {System.out.println("转换错误: " + e.getMessage());}}}/*** 连接错误* @param session* @param throwable* @throws IOException*/@OnErrorpublic void onError(Session session, Throwable throwable) throws IOException {log.error("websocket连接错误!");throwable.printStackTrace();}/*** 发送消息*/public void sendMessage(Session session, String message) throws IOException, EncodeException {if (session != null) {synchronized (session) {session.getBasicRemote().sendText(message);}}}/*** 给指定用户发送信息*/public void sendToUser(String userId, String message) {Session session = sessionPools.get(userId);try {if (session != null) {sendMessage(session, message);}else {log.debug("推送用户不在线");}} catch (Exception e) {e.printStackTrace();}}public static void addOnlineCount() {onlineNum.incrementAndGet();}public static void subOnlineCount() {onlineNum.decrementAndGet();}/*** 发送失败** @param userId       用户id* @param errorMessage 错误消息*/private void sendError(String userId, String errorMessage) {JSONObject obj = new JSONObject();obj.put("error", errorMessage);sendOneMessage(userId, obj.toString());}/*** 发送一个消息** @param userId  用户编号* @param message 消息*/public void sendOneMessage(String userId, String message) {Session session = sessionPools.get(userId);if (session != null && session.isOpen()) {try {synchronized (session) {session.getBasicRemote().sendText(message);}} catch (Exception e) {e.printStackTrace();}}}
}

核心代码

 private static ApplicationContext context;@Overridepublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException {context = applicationContext;}public static <roomService> roomService getBean(Class<roomService> beanClass) {return context.getBean(beanClass);}
Room room = context.getBean(IRoomService.class).selectRoomById(Long.parseLong(roomId));

原因:执行的先后顺序吧,具体还没仔细了解

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/71701.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

《A++ 敏捷开发》- 18 软件需求

需求并不是关于需求 (Requirements are not really about requirements) 大家去公共图书馆寄存物品&#xff0c;以前都是扫二维码开箱&#xff0c;有些图书馆升级了使用指纹识别。 “是否新方法比以前好&#xff1f;”我问年轻的开发人员。 “当然用指纹识别好。新技术&#x…

基于AMD AU15P FPGA的SLVS-EC桥PCIe设计方案分享

作者&#xff1a;Hello,Panda 各位FPGAer周末愉快&#xff0c;今天熊猫君分享一个基于AMD AU15P FPGA的SLVS-EC桥PCIe设计方案。 一、方案背景 先说方案的应用背景&#xff1a;众所周知&#xff0c;较为上层的如基于AI的机器视觉应用&#xff0c;大多基于高端的专用SoC、AI专…

Redis|Springboot集成Redis

文章目录 总体概述本地Java连接Redis常见问题集成Jedis集成lettuce集成RedisTemplate——推荐使用连接单机连接集群 总体概述 jedis-lettuce-RedisTemplate三者的联系 jedis第一代lettuce承上启下redistemplate着重使用 本地Java连接Redis常见问题 bind配置请注释掉保护模式…

机器学习(六)

一&#xff0c;决策树&#xff1a; 简介&#xff1a; 决策树是一种通过构建类似树状的结构&#xff08;颠倒的树&#xff09;&#xff0c;从根节点开始逐步对数据进行划分&#xff0c;最终在叶子节点做出预测结果的模型。 结构组成&#xff1a; 根节点&#xff1a;初始的数据集…

恢复IDEA的Load Maven Changes按钮

写代码的时候不知道点到什么东西了&#xff0c;pom文件上的这个弹窗就是不出来了&#xff0c;重启IDEA&#xff0c;reset windos都没用&#xff0c;网上搜也没收到解决方案 然后开打开其他项目窗口时&#xff0c;看到那个的功能名叫 Hide This Notification 于是跑到Setting里…

怎么使用Sam Helper修改手机屏幕分辨率,使得游戏视野变广?

1.准备Shizuku 和Sam Helper软件 2.打开设置&#xff0c;找到关于本机&#xff0c;连续点击版本号五次打开开发者选项 3.找到开发者选项&#xff0c;打开USB调试和无线调试 4.返回桌面&#xff0c;我们接着打开shizuku,点击配对&#xff0c;这里打开开发者选项&#xff0c;找…

【招聘精英】

我们公司是一个位于石家庄的一个科技型新型技术公司。主要做人力资源、用工、科技等方面。 有意向回石家庄的或者已经在石家庄的技术大咖、软件大牛、产品大佬、UI大神可以来了解一下。 现在招聘 高级前端开发 高级java开发 其他岗位也可以联系。 有意向的朋友可以私信我。 -…

大模型信息整理

1. Benchmarks Reasoning, conversation, Q&A benchmarks HellaSwagBIG-Bench HardSQuADIFEvalMuSRMMLU-PROMT-BenchDomain-specific benchmarks GPQAMedQAPubMedQAMath benchmarks GSM8KMATHMathEvalSecurity-related benchmarks PyRITPurple Llama CyberSecEval2. 国内外…

Redis-限流方案

在实际业务中&#xff0c;可能会遇到瞬时流量剧增的情况&#xff0c;大量的请求可能会导致服务器过载和宕机。为了保护系统自身和上下游服务&#xff0c;需要采用限流的方式&#xff0c;拒绝部分请求。 限流就是对请求的频率进行控制&#xff0c;迅速拒绝超过请求阈值的请求。 …

无感方波开环强拖总结

一、强拖阶段的核心原理与设计要点 开环换相逻辑 固定频率斜坡&#xff1a;以预设斜率逐步提升换相频率&#xff08;如0.5-5Hz/ms&#xff09;&#xff0c;强制电机跟随磁场旋转。电压-频率协调控制&#xff1a;初始阶段施加高电压&#xff08;80%-100%额定&#xff09;克服静摩…

Java虚拟机之垃圾收集(一)

目录 一、如何判定对象“生死”&#xff1f; 1. 引用计数算法&#xff08;理论参考&#xff09; 2. 可达性分析算法&#xff08;JVM 实际使用&#xff09; 3. 对象的“缓刑”机制 二、引用类型与回收策略 三、何时触发垃圾回收&#xff1f; 1. 分代回收策略 2. 手动触发…

代码随想录算法训练营第22天 | 组合 组合总和 电话号码的字母组合

77. 组合 77. 组合 - 力扣&#xff08;LeetCode&#xff09; class Solution {List<Integer> path new ArrayList<>();List<List<Integer>> result new ArrayList<>();public void backTracking(int n,int k,int startIndex){if(path.size() …

#UVM# 关于field automation机制中的标志位及if的使用

通过前面文章的复习,我们知道了 uvm_field 机制带来的好处,确实方便了我们很多代码的coding 时间,但是会不会有一种情况呢? 比如,我们不想将实例中的某一些成员进行打包、复制、比较操作,怎么办呢? 如果只执行 比较但不进行打包操作呢?是不是很复杂呢 ? 一 标志位…

RK3588 安装ffmpeg6.1.2

在安装 ffmpeg 在 RK3588 开发板上时,你需要确保你的开发环境(例如 Ubuntu、Debian 或其他 Linux 发行版)已经设置好了交叉编译工具链,以便能够针对 RK3588 架构编译软件。以下是一些步骤和指导,帮助你安装 FFmpeg: 1. 安装依赖项 首先,确保你的系统上安装了所有必要的…

leetcode day25 28 KMP算法

28找出字符串中第一个匹配项的下标 给你两个字符串 haystack 和 needle &#xff0c;请你在 haystack 字符串中找出 needle 字符串的第一个匹配项的下标&#xff08;下标从 0 开始&#xff09;。如果 needle 不是 haystack 的一部分&#xff0c;则返回 -1 。 示例 1&#xff…

编程语言介绍:Rust

什么是Rust Rust是由Mozilla研究院开发的一种系统级编程语言&#xff0c;旨在提供更好的内存安全保证&#xff0c;同时保持高性能&#xff0c;自2010年首次发布以来&#xff0c;Rust以其安全性、并发性和实用性迅速获得了广泛的关注。Rust最独特的特性之一是其所有权模型&#…

Java Spring MVC (2)

常见的Request Controller 和 Response Controller 的区别 用餐厅点餐来理解 想象你去一家餐厅吃饭&#xff1a; Request Controller&#xff08;接单员&#xff09;&#xff1a;负责处理你的点餐请求&#xff0c;记录你的口味、桌号等信息。Response Controller&#xff08…

Oracle 字符类型对比

本文以 Oracle12c 为例 1.主要区别对比 类型存储方式最大长度字符集支持适用场景备注​CHAR(M)固定长度空格填充2000 字节&#xff0c;M 代表字节长度默认字符集固定长度编码实际存储长度固定为定义长度&#xff08;如 CHAR(10) 始终占 10 字节&#xff09;​VARCHAR2(M)可变长…

Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露

一&#xff1a;背景 1. 讲故事 前面跟大家分享过一篇 C# 调用 C代码引发非托管内存泄露 的文章&#xff0c;这是一个故意引发的正向泄露&#xff0c;这一篇我们从逆向的角度去洞察引发泄露的祸根代码&#xff0c;这东西如果在 windows 上还是很好处理的&#xff0c;很多人知道开…

vite.config.js 是Vite 项目的配置文件,分析具体用法

vite.config.js 是 Vite 项目的配置文件&#xff0c;用于定义项目的构建、开发服务器、插件等配置选项。以下是示例代码中各部分的作用分析&#xff1a; 1. 导入模块 import { fileURLToPath, URL } from node:url import { defineConfig } from vite import vue from vitejs…