본문 바로가기

JAVA/SPRING

SpringBoot 2.6 이상 springfox-swagger3.0 적용 시 에러 해결

최신버전으로 

https://start.spring.io/ 에서 SpringBoot 프로젝트를 생성했다.

해당 옵션으로만 DB는 선택안하고 생성해 봤다.

Swagger2.0을 추가했는데 아래와 같은 에러가 발생했다.

Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null

원인은 SpringBoot 2.6 이상에서 springfox-swagger3.0를 추가할때 에러가 발생한 것이다.

해결은 SpringBoot 2.5 이하로 낮춘다. 또는 application.properties에서 spring.mvc.pathmatch.matching-strategy=ant_path_matcher로 default 값을 설정한다.

그리고 http://localhost:8080/swagger-ui/index.html#/ 이렇게 접속하면 된다.