1

Facing this issue while trying to upgrade spring from 5.1 to 5.2

enter image description here

enter image description here

@Configuration public class WebMvcConfiguration extends WebMvcConfigurationSupport {

@Override
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
    final RequestMappingHandlerMapping handlerMapping = super.requestMappingHandlerMapping();
    handlerMapping.setUseSuffixPatternMatch(false);
    handlerMapping.setUseTrailingSlashMatch(false);
    return handlerMapping;
}

}

This issue is setUseSuffixPatternMatch() method is deprecated from 5.2 version but can be used by giving arguments as false. I have given 'false' as argument but getting this error.

Is there any replacement methods for this methods.

And also I tried to remove setUseSuffixPatternMatch() method but I got this error

[18,66] method requestMappingHandlerMapping in class org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport cannot be applied to given types; [ERROR] required: org.springframework.web.accept.ContentNegotiationManager,org.springframework.format.support.FormattingConversionService,org.springframework.web.servlet.resource.ResourceUrlProvider

I'm not understanding why requestMappingHandlerMapping is not working when I try to upgrade spring 5.1 to 5.2

3 Answers3

0

You can use the next block:

@Override
public RequestMappingHandlerMapping createRequestMappingHandlerMapping() {
    final RequestMappingHandlerMapping handlerMapping = super.createRequestMappingHandlerMapping();
    handlerMapping.setUseSuffixPatternMatch(false);
    handlerMapping.setUseTrailingSlashMatch(false);
    return handlerMapping;
}

They only renamed the method

requestMappingHandlerMapping --> createRequestMappingHandlerMapping

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
0

Instead of these deprecated methods you can use the updated ones. PFB

public RequestMappingHandlerMapping requestMappingHandlerMapping(**ContentNegotiationManager mvcContentNegotiationManager,                                                       FormattingConversionService mvcConversionService,                                                                    ResourceUrlProvider mvcResourceUrlProvider**) {

    RequestMappingHandlerMapping handler = super.requestMappingHandlerMapping(m**vcContentNegotiationManager,
            mvcConversionService,
            mvcResourceUrlProvider**);

    handler.setUseSuffixPatternMatch(false);
    handler.setAlwaysUseFullPath(true);
    return handler;
}
rishi
  • 1
-1

Instead of these deprecated methods you can use the updated ones. PFB the link which gives you detailed information about the new methods available for the class.

https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.html