본문 바로가기
Web Develop/Spring

스프링 Swagger 오류 해결 - Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException

by tripleup 2023. 9. 2.
728x90
반응형

오류 발생

 

Spring boot에서 swagger를 사용하려고 build.gradle에 다음을 추가해줬다

 

dependencies {
    implementation 'io.springfox:springfox-swagger2:2.9.2'
    implementation 'io.springfox:springfox-swagger-ui:2.9.2'
}

 

그런데 서버를 실행하니 발생하는 오류

 

 

Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException

 

 

[전문]

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-09-02 21:17:15.201 ERROR 16064 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182) ~[spring-context-5.3.29.jar:5.3.29]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) ~[spring-context-5.3.29.jar:5.3.29]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:357) ~[spring-context-5.3.29.jar:5.3.29]
at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:156) ~[spring-context-5.3.29.jar:5.3.29]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:124) ~[spring-context-5.3.29.jar:5.3.29]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938) ~[spring-context-5.3.29.jar:5.3.29]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[spring-context-5.3.29.jar:5.3.29]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.15.jar:2.7.15]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731) ~[spring-boot-2.7.15.jar:2.7.15]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.15.jar:2.7.15]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[spring-boot-2.7.15.jar:2.7.15]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.7.15.jar:2.7.15]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.7.15.jar:2.7.15]
at co m.springboot.api.ApiApplication.main(ApiApplication.java:10) ~[classes/:na]

 

 

 

찾아보니까  Spring boot 2.6버전 이후에

 

spring.mvc.pathmatch.matching-strategy 값이

 

ant_apth_matcher -> path_pattern_parser로 변경되었다고 한다

 

그래서 라이브러리 일부에서 오류가 발생한 것!


해결방법

 

application.properties 파일에 다음을 추가해준다.

 

spring.mvc.pathmatch.matching-strategy=ant_path_matcher

 


결과

정상적으로 실행된다.

 

 


728x90
반응형

댓글