spring boot 2.6.0 使用swagger报 ‘documentationPluginsBootstrapper‘; java.lang.NullPointerException 错

在尝试使用Spring Boot 2.6.0和Swagger进行API文档集成时,遇到'documentationPluginsBootstrapper'启动异常,报NullPointerException。错误源于springfox库中的代码。通过将@EnableSwagger2注解替换为@EnableWebMvc,问题得到解决。参考Springfox官方文档以了解更多详情。
摘要由CSDN通过智能技术生成

pom 配置如下

<dependency>
   <groupId>io.springfox</groupId>
   <artifactId>springfox-boot-starter</artifactId>
   <version>3.0.0</version>
</dependency>

swagger 配置类

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo()).select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().build();
    }
}

启动应用会报错

org.springframework.context.ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring-context-5.3.10.jar:5.3.10]
at org.springframework.context.support.DefaultLifecycleProcessor.accessKaTeX parse error: Undefined control sequence: \[ at position 41: …ssor.java:54) ~\̲[̲spring-context-…LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[spring-context-5.3.10.jar:5.3.10]
at java.base/java.lang.Iterable.forEa

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值