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

com.zyy.common.config.MvcConfig Maven / Gradle / Ivy

package com.zyy.common.config;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zyy.common.resolver.InitResolver;
import com.zyy.common.resolver.SearchResolver;
import com.zyy.common.util.ApplicationUtil;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : li.yang
 * @version : 1.0
 * Date : 2020/6/8 9:51
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Resource
    private DiscoveryClient discoveryClient;

    @Override
    public void addArgumentResolvers(List resolvers) {
        resolvers.add(new InitResolver(objectMapper()));
        resolvers.add(new SearchResolver(objectMapper()));
    }

    @Bean
    public ObjectMapper objectMapper() {
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
        return mapper;
    }

    @Bean
    public ApplicationUtil applicationUtil() {
        return new ApplicationUtil(discoveryClient);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy