public class CustomerRequestMappingHandlerMapping extends RequestMappingHandlerMapping{
private RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration();
@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
RequestMappingInfo info = super.getMappingForMethod(method, handlerType);
if (info != null) {
ApiVersion apiVersion = handlerType.getAnnotation(ApiVersion.class);
if (apiVersion == null) {
return info;
}
PathPatternParser patternParser = getPatternParser();
if (this.config.getPatternParser() == null) {
this.config.setPatternParser(patternParser);
}
info = RequestMappingInfo.paths(buildPrefix(apiVersion.value()))
.options(this.config)
.build()
.combine(info);
}
return info;
}
}
@Configuration
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
@Override
protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() {
return new CustomerRequestMappingHandlerMapping ();
}
}