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

com.icthh.xm.commons.web.spring.config.JacksonConfiguration Maven / Gradle / Ivy

package com.icthh.xm.commons.web.spring.config;

import com.fasterxml.jackson.datatype.hibernate6.Hibernate6Module;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.SpringHandlerInstantiator;

@Configuration
public class JacksonConfiguration {

    /**
     * Support for Java date and time API.
     * @return the corresponding Jackson module.
     */
    @Bean
    public JavaTimeModule javaTimeModule() {
        return new JavaTimeModule();
    }

    @Bean
    public Jdk8Module jdk8TimeModule() {
        return new Jdk8Module();
    }

    /*
     * Support for Hibernate types in Jackson.
     */

    @Bean
    public Hibernate6Module hibernate6Module() {
        return new Hibernate6Module();
    }

    @Bean
    public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilder(
            AutowireCapableBeanFactory beanFactory) {
        return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder
                .handlerInstantiator(new SpringHandlerInstantiator(beanFactory));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy