gitlab-runner-gateway/src/main/java/tk/antoine_roux/wiki/configuration/WebConfiguration.java

41 lines
1.5 KiB
Java
Raw Normal View History

package tk.antoine_roux.wiki.configuration;
2020-10-03 15:03:48 +00:00
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
2020-09-15 23:04:29 +00:00
import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;
2020-10-03 15:03:48 +00:00
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
2020-10-03 15:03:48 +00:00
import org.springframework.context.annotation.Primary;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import tk.antoine_roux.wiki.utilitary.Constant;
/**
* spring web configuration
2020-09-15 23:04:29 +00:00
*
* @see org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations
*/
@Configuration(proxyBeanMethods = false)
2020-09-15 23:04:29 +00:00
public class WebConfiguration implements WebMvcRegistrations {
@Override
2020-09-15 23:04:29 +00:00
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
return new ApiVersionRequestMappingHandlerMapping(Constant.VERSION_PREFIX);
}
2020-10-03 15:03:48 +00:00
/**
* build default Spring boot {@link ObjectMapper}
* this bean avoid spring boot to auto detect {@link GitConfiguration#ObjectMapper(YAMLFactory)}
* as default {@link ObjectMapper}
*
* @param jackson2ObjectMapperBuilder
* @return
*/
@Bean
@Primary
public ObjectMapper jackson2ObjectMapperBuilder(Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder) {
return jackson2ObjectMapperBuilder.build();
}
}