当前位置: 代码网 > it编程>编程语言>Java > SpringBoot2.6.x 与 Swagger3 兼容问题及解决方法

SpringBoot2.6.x 与 Swagger3 兼容问题及解决方法

2025年03月21日 Java 我要评论
报错:failed to start bean 'documentationpluginsbootstrapper'; nested exception is java.lang.nu

报错:

failed to start bean 'documentationpluginsbootstrapper'; nested exception is java.lang.nullpointerexception

解决:

​ 如果项目中未引入 spring-boot-starter-actuator,则直接在 yml 文件中加入如下配置:

spring:
  mvc:
    pathmatch:
      matching-strategy: ant-path-matcher

​ 反之再添加如下配置:

@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));
}

到此这篇关于springboot2.6.x 与 swagger3 兼容问题的文章就介绍到这了,更多相关springboot2.6.x 与 swagger3 兼容问题内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com