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

spring.turbo.autoconfiguration.ObjectMapperEditingAutoConfiguration Maven / Gradle / Ivy

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *    ____             _            _____           _
 *   / ___| _ __  _ __(_)_ __   __ |_   _|   _ _ __| |__   ___
 *   \___ \| '_ \| '__| | '_ \ / _` || || | | | '__| '_ \ / _ \
 *    ___) | |_) | |  | | | | | (_| || || |_| | |  | |_) | (_) |
 *   |____/| .__/|_|  |_|_| |_|\__, ||_| \__,_|_|  |_.__/ \___/
 *         |_|                 |___/   https://github.com/yingzhuo/spring-turbo
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package spring.turbo.autoconfiguration;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import spring.turbo.jackson2.CoreModuleJackson2Module;

/**
 * @author 应卓
 * @since 1.3.0
 */
@AutoConfiguration
@ConditionalOnClass(name = "com.fasterxml.jackson.databind.ObjectMapper")
@ConditionalOnBean(type = "com.fasterxml.jackson.databind.ObjectMapper")
public class ObjectMapperEditingAutoConfiguration implements InitializingBean {

    private final ObjectMapper objectMapper;

    /**
     * 构造方法
     *
     * @param om 要注入的 {@link ObjectMapper} 实例
     */
    public ObjectMapperEditingAutoConfiguration(ObjectMapper om) {
        this.objectMapper = om;
    }

    @Override
    public void afterPropertiesSet() {
        objectMapper.registerModule(new CoreModuleJackson2Module());
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy