parent
93f1ba0d77
commit
97826be003
@ -0,0 +1,23 @@
|
|||||||
|
package com.zhehekeji.web.config;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||||
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
public class CustomJacksonHttpMessageConverter extends MappingJackson2HttpMessageConverter {
|
||||||
|
public CustomJacksonHttpMessageConverter() {
|
||||||
|
this(Jackson2ObjectMapperBuilder.json().build());
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomJacksonHttpMessageConverter(ObjectMapper objectMapper) {
|
||||||
|
super(objectMapper);
|
||||||
|
// 这里是重点,增加支持的类型,看你的情况加
|
||||||
|
// 我这里目前只需要加个 TEXT/PLAIN
|
||||||
|
setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN,
|
||||||
|
MediaType.APPLICATION_JSON,
|
||||||
|
new MediaType("application", "*+json")));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.zhehekeji.web.test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.Socket;
|
||||||
|
|
||||||
|
public class TR {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
for (;;){
|
||||||
|
// 创建TCP客户端并连接到服务器
|
||||||
|
Thread thread = new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
String serverAddress = "127.0.0.1";
|
||||||
|
int serverPort = 8888;
|
||||||
|
try {
|
||||||
|
Socket clientSocket = new Socket(serverAddress, serverPort);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
thread.start();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue