@@ -1,5 +1,6 @@ | |||
package com.tuoheng.airportGzdp.config; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import lombok.SneakyThrows; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
@@ -52,7 +53,11 @@ public class WebSocket { | |||
} | |||
public void handleData(String code){ | |||
WebSocketClient webSocketClient = new WebSocketClient(); | |||
//修改获取bean的方式 重新new一个实例 导致 @value 获取不到配置的文件 | |||
//webSocketClient webSocketClient = new WebSocketClient(); | |||
if (ObjectUtil.isEmpty(webSocketClient)){ | |||
webSocketClient = SpringUtil.getBean(WebSocketClient.class); | |||
} | |||
webSocketClient.connectWebsocket(code); | |||
} | |||
@@ -1,8 +1,6 @@ | |||
package com.tuoheng.airportGzdp.config; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.tuoheng.airportGzdp.service.impl.TaskServiceImpl; | |||
import com.tuoheng.airportGzdp.until.SpringUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.beans.factory.annotation.Value; | |||
@@ -17,6 +15,10 @@ import java.net.URI; | |||
@Slf4j | |||
public class WebSocketClient { | |||
@Value("${interfaceUrl}") | |||
private String interfaceUrl; | |||
@Autowired | |||
WebSocket webSocket; | |||
public static Session session; | |||
@@ -48,7 +50,10 @@ public class WebSocketClient { | |||
if (session!=null&&session.isOpen()){ | |||
return; | |||
} | |||
String url = SpringUtil.getProperty("websocketurl")+"/0:0:"+code; | |||
//修改获取配置方式 | |||
//String url = SpringUtil.getProperty("websocketurl")+"/0:0:"+code; | |||
String url = interfaceUrl +"/0:0:"+code; | |||
session = container.connectToServer(WebSocketClient.class, URI.create(url)); | |||
//session.getBasicRemote().sendText("Hello, server!"); // 发送消息给服务器 | |||
log.info("websocket请求地址{}",url); |
@@ -41,4 +41,5 @@ mybatis-plus: | |||
configuration: | |||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 | |||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl | |||
interfaceUrl: https://airport.t-aaron.com/airport/admin/airportInterface | |||
interfaceUrl: https://airport.t-aaron.com/airport/admin/airportInterface | |||
websocketurl: wss://airport-test.t-aaron.com/airport/socket/webSocket |
@@ -41,4 +41,5 @@ | |||
configuration: | |||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 | |||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl | |||
interfaceUrl: https://airport.t-aaron.com/airport/admin/airportInterface | |||
interfaceUrl: https://airport.t-aaron.com/airport/admin/airportInterface | |||
websocketurl: wss://airport.t-aaron.com/airport/socket/webSocket |
@@ -41,4 +41,5 @@ mybatis-plus: | |||
configuration: | |||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 | |||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl | |||
interfaceUrl: https://airport-test.t-aaron.com/airport/admin/airportInterface | |||
interfaceUrl: https://airport-test.t-aaron.com/airport/admin/airportInterface | |||
websocketurl: wss://airport-test.t-aaron.com/airport/socket/webSocket |
@@ -1,2 +1 @@ | |||
#注意,打包发布时需确认地址 | |||
websocketurl: wss://airport-test.t-aaron.com/airport/socket/webSocket |