Dipesh Garg
Dipesh Garg

Reputation: 375

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

Upvotes: 25

Views: 42153

Answers (5)

EtwinCorp
EtwinCorp

Reputation: 115

It seems using CAPS is working:

spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER

Upvotes: 4

Edward Abattam
Edward Abattam

Reputation: 91

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

spring.mvc.pathmatch.matching-strategy=ant_path_matcher

Upvotes: 6

Martin Devillers
Martin Devillers

Reputation: 18002

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

Upvotes: 6

franky75ch
franky75ch

Reputation: 171

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

Upvotes: 17

609612189
609612189

Reputation: 181

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.

Upvotes: 18

Related Questions