'Getting following error while migrating Spring boot version from 2.1.6 to Spring boot 2.4

Getting following error while migrating my project from Spring boot version 2.1.6 to 2.4

No more pattern data allowed after {*...} or ** pattern element

Code Snippet where error is coming

public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authInterceptor)
                .addPathPatterns("/**/test/**")
    }
}

I know Spring boot disable AntPathMatcher in version 2.4 , so I tried this option as well

Spring.mvc.pathpattern.matching-strategy= ant_path_matcher

but even this is not working

Any help is much appreciated



Solution 1:[1]

With the newest version 1.5.12 of springdoc-openapi-ui the problem is solved for me.

Solution 2:[2]

the reason: The error is a path wildcard problem. The search found that the path wildcard has changed after the spring upgrade to 5.3. The official explanation is "In Spring MVC, the path was previously analyzed by AntPathMatcher, but it was changed to use PathPatternParser introduced in WebFlux from Spring 5.3.0.".

solve: The specific solution is to change /**/*.css to /*/*.css. Multiple files may be involved in the project, and they must be changed.

Solution 3:[3]

Set this in your application.properties. Either that or just edit the patterns.

spring.mvc.pathmatch.matching-strategy=ant_path_matcher

Solution 4:[4]

Please note that in newer versions of Spring the correct property is spring.mvc.pathmatch.matching-strategy (and not spring.mvc.pathpattern.matching-strategy)

More info: https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#application-properties.web.spring.mvc.pathmatch.matching-strategy

Relevant issue: https://github.com/spring-projects/spring-boot/issues/28791

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 franky75ch
Solution 2 609612189
Solution 3 Christian Cavuti
Solution 4 Martin Devillers