-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Currently WebMvcConfigurer.configurePathMatch(...) is called as a side-effect of WebMvcConfigurationSupport.getPathMatchConfigurer(). This makes it quite hard to use in @Bean method since it's hard to tell if the @Bean method or the configurePathMatch(...) method will be called first.
You can see an example of this in Spring Data Rest where the restHandlerMapping bean would ideally have a PatternParser on the delegates before the afterPropertiesSet() method is called. The current solution of overriding configurePathMatch and calling setPatternParser directly is brittle because the parser is needed before afterPropertiesSet() is called. This leads to issues such as #26415
It's possible to work-around the issue by adding @DependsOn("mvcPathMatcher") which will indirectly trigger the WebMvcConfigurationSupport.getPathMatchConfigurer() method, but this isn't ideal.
I wonder if we could make PathMatchConfigurer or the PatternParser a @Bean so that it can be injected directly if it's needed?