41 lines
1.5 KiB
Java
41 lines
1.5 KiB
Java
package tk.antoine_roux.wiki.configuration;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
|
import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
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
|
|
*
|
|
* @see org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations
|
|
*/
|
|
@Configuration(proxyBeanMethods = false)
|
|
public class WebConfiguration implements WebMvcRegistrations {
|
|
|
|
@Override
|
|
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
|
|
return new ApiVersionRequestMappingHandlerMapping(Constant.VERSION_PREFIX);
|
|
}
|
|
|
|
/**
|
|
* 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();
|
|
}
|
|
}
|