marble log

Webエンジニアの技術ブログです

SpringFoxのFailed to start bean 'documentationPluginsBootstrapper'を対処する

現象

Spring Bootで書いたWebアプリケーションにSwaggerを導入するため、SpringFoxを依存関係(build.gradle)に含めた。

implementation "io.springfox:springfox-boot-starter:3.0.0"

アプリケーションを起動したところ、documentationPluginsBootstrapper Beanがスタートできない旨のエラーが発生し、アプリケーションが起動できなくなった。

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
...

環境

  • Java 17
  • SpringBoot 2.6.x、2.7.x

上記以外の環境では確認していないが起こる可能性あり。

対処法

application propertyに以下のプロパティを加える。

application.propertiesの場合↓

spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER

application.ymlの場合↓

spring:
  mvc:
    pathmatch:
      matching-strategy: ANT_PATH_MATCHER

参考

github.com