[Spring Boot] No more pattern data allowed after {*...} or ** pattern element 에러 수정
에러 난 부분
package com.bootblog.springbootblog.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/board/**")
public class BoardController {
@GetMapping("/hello")
public String Hello() {
return "/boards/hello";
}
}
해당 코드에서 No more pattern data allowed after {*...} or ** pattern element 오류가 떴다.
@RequestMapping("/board/**")에서 오류가 떴음을 파악했다.
프로젝트 생성 시 제일 낮은 버전이 2.7.x 였나 그랬어서 2.7.x로 프로젝트를 생성했는데 2.5 버전에서 2.6 버전으로 업그레이드 되면서 해당 /** 방식이 오류가 뜨는 걸로 바뀌었다고 한다.
해결 방법
참고한 블로그에서는 두가지의 해결 방법을 제시했다.
1. application.properties 에서 ant_path_matcher 값을 default 값으로 변경
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
2. Spring Boot 버전을 2.5.x로 낮추는 방법
수정
1번 방법을 진행할 경우 ant_path_matcher에 빨간줄이 뜨길래 2번 방법으로 진행했다.
build.gradle
plugins {
id 'org.springframework.boot' version '2.5.7'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'java'
}
해당 부분의 두번째 라인 숫자를 수정하면 된다.
id 'org.springframework.boot' version '2.5.x'
수정 후 새로 생기는 Load Gradle Changes 버튼을 눌러 프로젝트를 새로 업데이트 하면 된다.
참고
https://haenny.tistory.com/297
SpringBoot 2.5 → 2.6 업그레이드 시No more pattern data allowed after {*...} or ** pattern element 오류 해
오류 로그 No more pattern data allowed after {*...} or ** pattern element ********************************* APPLICATION FAILED TO START ********************************* Description: Invalid mapping..
haenny.tistory.com