Browse Source

修改编码

Lucien 1 year ago
parent
commit
301a466189

+ 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);