好友
阅读权限10
听众
最后登录1970-1-1
|
41吾爱币
在spring boot系统里的聊天系统里运行数据库语句,autowired 注入为null运行不起来,求助
代码在这
@Component
@ServerEndpoint(value = "/chat")
public class ChatEndpoint {
@Autowired
private AuctionMapper auctionMapper;
private static Set<Session> clients = Collections.synchronizedSet(new HashSet<>());
@OnOpen
public void onOpen(Session session) {
clients.add(session);
}
@OnClose
public void onClose(Session session) {
clients.remove(session);
}
@OnMessage
public void onMessage(String message, Session session) throws IOException, SQLException {
System.out.println("我是mess"+message);
JSONObject json = new JSONObject(message);
String text = json.getString("text");
String senderId = String.valueOf(json.getInt("senderId"));
String receiverId = String.valueOf(json.getInt("receiverId"));
Message mg = new Message();
mg.setSenderId(senderId);
mg.setReceiverId(receiverId);
mg.setJsonMsg(text);
auctionMapper.InIoMessage(mg);
|
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|