diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml
index 767f90a6a6..b05a795c6d 100644
--- a/spring-rest/pom.xml
+++ b/spring-rest/pom.xml
@@ -155,7 +155,16 @@
spring-test
${spring.version}
-
+
+ com.google.protobuf
+ protobuf-java
+ 2.6.1
+
+
+ com.esotericsoftware.kryo
+ kryo
+ 2.24.0
+
diff --git a/spring-rest/src/main/java/org/baeldung/config/WebConfig.java b/spring-rest/src/main/java/org/baeldung/config/WebConfig.java
index 999f890ebb..120f1b272a 100644
--- a/spring-rest/src/main/java/org/baeldung/config/WebConfig.java
+++ b/spring-rest/src/main/java/org/baeldung/config/WebConfig.java
@@ -3,11 +3,13 @@ package org.baeldung.config;
import java.text.SimpleDateFormat;
import java.util.List;
+import org.baeldung.config.converter.KryoHttpMessageConverter;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter;
import org.springframework.http.converter.xml.MarshallingHttpMessageConverter;
import org.springframework.oxm.xstream.XStreamMarshaller;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@@ -33,7 +35,8 @@ public class WebConfig extends WebMvcConfigurerAdapter {
builder.indentOutput(true).dateFormat(new SimpleDateFormat("dd-MM-yyyy hh:mm"));
messageConverters.add(new MappingJackson2HttpMessageConverter(builder.build()));
// messageConverters.add(new MappingJackson2XmlHttpMessageConverter(builder.createXmlMapper(true).build()));
-
+ messageConverters.add(new ProtobufHttpMessageConverter());
+ messageConverters.add(new KryoHttpMessageConverter());
super.configureMessageConverters(messageConverters);
}
diff --git a/spring-rest/src/main/java/org/baeldung/config/converter/KryoHttpMessageConverter.java b/spring-rest/src/main/java/org/baeldung/config/converter/KryoHttpMessageConverter.java
new file mode 100644
index 0000000000..7e63a3ba9e
--- /dev/null
+++ b/spring-rest/src/main/java/org/baeldung/config/converter/KryoHttpMessageConverter.java
@@ -0,0 +1,57 @@
+package org.baeldung.config.converter;
+
+import java.io.IOException;
+
+import org.baeldung.web.dto.Foo;
+import org.springframework.http.HttpInputMessage;
+import org.springframework.http.HttpOutputMessage;
+import org.springframework.http.MediaType;
+import org.springframework.http.converter.AbstractHttpMessageConverter;
+
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.io.Input;
+import com.esotericsoftware.kryo.io.Output;
+
+/**
+ * An {@code HttpMessageConverter} that can read and write Kryo messages.
+ */
+public class KryoHttpMessageConverter extends AbstractHttpMessageConverter