解决报错 ,启动类启动不起来,关于swagger

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

使用springboot2.6.0后,配置swagger,不论是2.9.2还是3.0.0都报错

解决方法:配置文件中加入 application.yml 

spring:
  mvc:
    pathmatch:
      matching-strategy: ant_path_matcher

还有另一种情况:

       没有获取到你的swaggerConfig配置类,这种情况在启动类上加个注解就行

     二选其一便可:
        @ComponentScan(value = "com.buba.config")
        @Import(SwaggerConfig.class)

        

@SpringBootApplication
@ComponentScan(value = "com.buba.config")
//@Import(SwaggerConfig.class)
public class UserApplication {
    public static void main(String[] args) {
        SpringApplication.run(UserApplication.class,args);
    }
}

 


版权声明:本文为kjahe原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。