All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jdkhome.blzo.ex.basic.configuration.CustomConfiguration Maven / Gradle / Ivy

There is a newer version: 0.5.0.3.RELEASE
Show newest version
package com.jdkhome.blzo.ex.basic.configuration;

import com.google.gson.Gson;
import com.jdkhome.blzo.ex.utils.tools.gson.PerfectGson;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
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 java.util.ArrayList;
import java.util.Collection;

@Configuration
public class CustomConfiguration {


    @Bean
    public HttpMessageConverters customConverters() {
        Collection> messageConverters = new ArrayList<>();
        messageConverters.add(createGsonHttpMessageConverter());
        return new HttpMessageConverters(true, messageConverters);
    }

    private GsonHttpMessageConverter createGsonHttpMessageConverter() {
        Gson gson = PerfectGson.getGson();
        GsonHttpMessageConverter gsonConverter = new GsonHttpMessageConverter();
        gsonConverter.setGson(gson);
        return gsonConverter;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy