Error

Fix this pattern in your application or switch to the legacy parser implementation with 'spring.mvc.pathmatch.matching-strategy=ant_path_matcher'.

luminous13 2022. 9. 22. 09:39

에러로그

Description:

Invalid mapping pattern detected: /{/user-id}
  ^
Expected close capture character after variable name }

Action:

Fix this pattern in your application or switch to the legacy parser implementation with 'spring.mvc.pathmatch.matching-strategy=ant_path_matcher'.

 

원인

스프링 부트가 2.5에서 2.6으로 버전이 올라가면서 ControllerHandler 매칭 전략이 ant_path_matcher에서 path_pattern_parser로 변경되었기 때문이다. 

 

해결

방법은 크게 2가지가 있다.

첫 번째는 application.properties에 명시적으로 매칭 전략을 ant_path_matcher로  설정한다.

spring.mvc.pathmatch.matching-strategy=ant_path_matcher

두 번째는 스프링부트 버전을 다운그레이드하여 2.5로 바꾸는 것이다.

스프링부트의 버전을 전체 다운하는 것보다는 매칭전략만 바꾸는게 변화가 적다는 점에서 더 안전하고 간편하여 나는 첫 번째 방법을 선택했다.