java - 转换为 Maven 项目时 Java Web Socket 不起作用
问题描述
我正在创建动态网络项目。
我有课:
@ServerEndpoint("/websocketendpoint")
public class WsServer {
@OnOpen
public void onOpen( Session session){
System.out.println("Open Connection ...");
PushTimeService.initialize();
PushTimeService.add(session);
}
@OnClose
public void onClose(){
System.out.println("Close Connection ...");
}
@OnMessage
public String onMessage(String message){
System.out.println("Message from the client: " + message);
String echoMsg = "Echo from the server : " + message;
return echoMsg;
}
@OnError
public void onError(Throwable e){
e.printStackTrace();
}
}
使用 tomcat 运行项目,我可以从 JS 文件访问 URI:
ws://localhost:8080/WebSocketStream/websocketendpoint
但是我需要在项目中添加一些额外的 *.jar 并添加一些ReastEASY
方法,因此我需要将其转换为 Maven 项目。
我正在用 Eclipse 做,转换为 maven 项目。但是在构建阶段之后,我无法访问 URI,得到 404 代码。
我尝试在 URI 中添加版本号,如下所示:
ws://localhost:8080/WebSocketStream-1.0/websocketendpoint
但结果相同,我无法访问它。
请建议。
解决方案
推荐阅读
- r - 在 Mambaforge 的 Snakemake 工作流程中使用 R
- angular - 在返回值之前等待 observable 在每个数组中完成
- python - Prolog 嵌套查询
- node.js - Dynamo DB 上的节点 JS 查询使用 IAM 角色永远挂起
- optimization - 复杂的布尔表达式优化,范式?
- java - Jackson序列化XML与根到抽象类
- string - 我有一个字符串,需要将该字符串与 TCL 中的字符串列表进行比较
- node.js - Redis 哨兵连接从 nodeJS 超时
- azure - 当我在 Python 中有瀑布步骤上下文对象时,如何集成 LUIS?
- python - 我需要在发布 python 包时上传额外的文件夹