Replace Jackson with Gson
This commit is contained in:
parent
fbdd2fc9a7
commit
b8abef9cff
8
pom.xml
8
pom.xml
@ -48,6 +48,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
|
||||||
|
<!-- Exclude the default Jackson dependency -->
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-json</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Redis for caching -->
|
<!-- Redis for caching -->
|
||||||
|
@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||||
@ -21,11 +22,11 @@ import java.util.Objects;
|
|||||||
/**
|
/**
|
||||||
* @author Braydon
|
* @author Braydon
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication
|
@SpringBootApplication(exclude = { JacksonAutoConfiguration.class })
|
||||||
@Slf4j(topic = "RESTfulMC")
|
@Slf4j(topic = "RESTfulMC")
|
||||||
public class RESTfulMC {
|
public class RESTfulMC {
|
||||||
public static final Gson GSON = new GsonBuilder()
|
public static final Gson GSON = new GsonBuilder()
|
||||||
.serializeNulls()
|
.setDateFormat("MM-dd-yyyy HH:mm:ss")
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
29
src/main/java/me/braydon/mc/config/WebMvcConfig.java
Normal file
29
src/main/java/me/braydon/mc/config/WebMvcConfig.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package me.braydon.mc.config;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import me.braydon.mc.RESTfulMC;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
|
import org.springframework.http.converter.json.GsonHttpMessageConverter;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Braydon
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class WebMvcConfig implements WebMvcConfigurer {
|
||||||
|
@Override
|
||||||
|
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||||
|
GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter();
|
||||||
|
gsonHttpMessageConverter.setGson(gson());
|
||||||
|
converters.add(gsonHttpMessageConverter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Gson gson() {
|
||||||
|
return RESTfulMC.GSON;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package me.braydon.mc.model.response;
|
package me.braydon.mc.model.response;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
@ -26,7 +25,6 @@ public final class ErrorResponse {
|
|||||||
/**
|
/**
|
||||||
* The timestamp this error occurred.
|
* The timestamp this error occurred.
|
||||||
*/
|
*/
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy hh:mm:ss")
|
|
||||||
private Date timestamp;
|
private Date timestamp;
|
||||||
|
|
||||||
public ErrorResponse(@NonNull HttpStatus status, @NonNull String message) {
|
public ErrorResponse(@NonNull HttpStatus status, @NonNull String message) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package me.braydon.mc.model.token;
|
package me.braydon.mc.model.token;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
Loading…
Reference in New Issue
Block a user