尝试将Spring版本从5.1升级到5.2时出现错误

时间:2020-10-16 09:16:11

标签: spring version spring5

在尝试将Spring从5.1升级到5.2时遇到此问题

enter image description here

enter image description here

@配置 公共类WebMvcConfiguration扩展了WebMvcConfigurationSupport {

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

}

此问题是setUseSuffixPatternMatch()方法从5.2版本开始不推荐使用,但可以通过将参数设置为false来使用。我已经给了'false'作为参数,但是出现了这个错误。

此方法是否有替代方法。

我也尝试删除setUseSuffixPatternMatch()方法,但出现此错误

不能在类org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport中使用

[18,66]方法requestMappingHandlerMapping; 需要[错误]:org.springframework.web.accept.ContentNegotiationManager,org.springframework.format.support.FormattingConversionService,org.springframework.web.servlet.resource.ResourceUrlProvider

当我尝试将Spring 5.1升级到5.2时,我不理解为什么requestMappingHandlerMapping无法正常工作

1 个答案:

答案 0 :(得分:0)

可以使用更新的方法来代替这些不建议使用的方法。 PFB链接为您提供了有关该类可用的新方法的详细信息。

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