瀏覽代碼

修改编码

Lucien 1 年之前
父節點
當前提交
301a466189
共有 2 個文件被更改,包括 3 次插入1 次删除
  1. 1 0
      pom.xml
  2. 2 1
      src/main/java/com/keystar/plane/inspection/service/impl/MqttServiceImpl.java

+ 1 - 0
pom.xml

@@ -18,6 +18,7 @@
 	<packaging>jar</packaging>
 
 	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 		<java.version>1.8</java.version>
 		<maven.compiler.source>${java.version}</maven.compiler.source>
 		<maven.compiler.target>${java.version}</maven.compiler.target>

+ 2 - 1
src/main/java/com/keystar/plane/inspection/service/impl/MqttServiceImpl.java

@@ -53,7 +53,8 @@ public class MqttServiceImpl implements MqttService {
         MqttMessage mqttMessage = new MqttMessage();
         Map<String, Object> map = new HashMap<>();
         map.put("data", messageBos);
-        byte[] bytes = OBJECT_MAPPER.writeValueAsBytes(map);
+        String mStr = OBJECT_MAPPER.writeValueAsString(map);
+        byte[] bytes = mStr.getBytes(StandardCharsets.UTF_8);
         mqttMessage.setPayload(bytes);
         try {
             mqttAsyncClient.publish("LightSpot_recognize",mqttMessage);