‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointe

异常信息

Failed to start bean 'documentationPluginsBootstrapper' ........

尝试使用 spring.mvc.pathmatch.matching-strategy: ant_path_matcher,未生效。这是网上大多数的解决办法

环境依赖
jdk8
spring boot 2.6.3
swagger [springfox-boot-starter(3.0.0)]
解决在github 查找到issues https://github.com/springfox/springfox/issues/3462,找到解决办法,整理如下

首先需要添加配置(必须)

spring.mvc.pathmatch.matching-strategy=ant_path_matcher

配置 WebMvcEndpointHandlerMapping Bean(必须)可以添加在swagger configure中


    @Bean
    public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(WebEndpointsSupplier webEndpointsSupplier, ServletEndpointsSupplier servletEndpointsSupplier, ControllerEndpointsSupplier controllerEndpointsSupplier, EndpointMediaTypes endpointMediaTypes, CorsEndpointProperties corsProperties, WebEndpointProperties webEndpointProperties, Environment environment) {
        List<ExposableEndpoint<?>> allEndpoints = new ArrayList();
        Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
        allEndpoints.addAll(webEndpoints);
        allEndpoints.addAll(servletEndpointsSupplier.getEndpoints());
        allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
        String basePath = webEndpointProperties.getBasePath();
        EndpointMapping endpointMapping = new EndpointMapping(basePath);
        boolean shouldRegisterLinksMapping = this.shouldRegisterLinksMapping(webEndpointProperties, environment, basePath);
        return new WebMvcEndpointHandlerMapping(endpointMapping, webEndpoints, endpointMediaTypes, corsProperties.toCorsConfiguration(), new EndpointLinksResolver(allEndpoints, basePath), shouldRegisterLinksMapping, null);
    }

    private boolean shouldRegisterLinksMapping(WebEndpointProperties webEndpointProperties, Environment environment, String basePath) {
        return webEndpointProperties.getDiscovery().isEnabled() && (StringUtils.hasText(basePath) || ManagementPortType.get(environment).equals(ManagementPortType.DIFFERENT));
    }

转载请注明出处:

转载自http://lxfamn.cn/blog

未经允许不得转载:lxfamn » ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointe

赞 (0) 打赏

置顶推荐

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏