SpringBoot2.6.x 與 Swagger3 兼容問題及解決方法
報(bào)錯(cuò):
Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
解決:
? 如果項(xiàng)目中未引入 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));
}到此這篇關(guān)于SpringBoot2.6.x 與 Swagger3 兼容問題的文章就介紹到這了,更多相關(guān)SpringBoot2.6.x 與 Swagger3 兼容問題內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
SpringBoot配置攔截器實(shí)現(xiàn)過程詳解
在系統(tǒng)中經(jīng)常需要在處理用戶請(qǐng)求之前和之后執(zhí)行一些行為,例如檢測(cè)用戶的權(quán)限,或者將請(qǐng)求的信息記錄到日志中,即平時(shí)所說的"權(quán)限檢測(cè)"及"日志記錄",下面這篇文章主要給大家介紹了關(guān)于在SpringBoot項(xiàng)目中整合攔截器的相關(guān)資料,需要的朋友可以參考下2022-10-10
SpringMVC實(shí)現(xiàn)獲取請(qǐng)求參數(shù)方法詳解
Spring MVC 是 Spring 提供的一個(gè)基于 MVC 設(shè)計(jì)模式的輕量級(jí) Web 開發(fā)框架,本質(zhì)上相當(dāng)于 Servlet,Spring MVC 角色劃分清晰,分工明細(xì),這篇文章主要介紹了SpringMVC實(shí)現(xiàn)獲取請(qǐng)求參數(shù)方法2022-09-09
Java連接Emqx實(shí)現(xiàn)訂閱發(fā)布消息的步驟記錄
這篇文章主要介紹了Java連接Emqx實(shí)現(xiàn)訂閱發(fā)布消息的步驟記錄,EMQX是大規(guī)模分布式MQTT消息服務(wù)器,可以高效可靠連接海量物聯(lián)網(wǎng)設(shè)備,實(shí)時(shí)處理分發(fā)消息與事件流數(shù)據(jù),助力構(gòu)建關(guān)鍵業(yè)務(wù)的物聯(lián)網(wǎng)與云應(yīng)用,需要的朋友可以參考下2025-09-09
Java中finally和return的關(guān)系實(shí)例解析
這篇文章主要介紹了Java中finally和return的關(guān)系實(shí)例解析,總結(jié)了二者的關(guān)系,然后分享了相關(guān)代碼示例,小編覺得還是挺不錯(cuò)的,具有一定借鑒價(jià)值,需要的朋友可以參考下2018-02-02
做java這么久了居然還不知道JSON的使用(一文帶你了解)
這篇文章主要介紹了做java這么久了居然還不知道JSON的使用(一文帶你了解),本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-07-07
Java生成遞增流水號(hào)(編號(hào)+時(shí)間+流水號(hào))簡(jiǎn)單示例
這篇文章主要給大家介紹了關(guān)于Java生成遞增流水號(hào)(編號(hào)+時(shí)間+流水號(hào))的相關(guān)資料,在開發(fā)項(xiàng)目漫長(zhǎng)的過程中常常會(huì)遇到流水號(hào)需要自動(dòng)生成的問題存在,文中給出了詳細(xì)的代碼示例,需要的朋友可以參考下2023-07-07
SpringBoot結(jié)合Vue實(shí)現(xiàn)Python在線調(diào)試器
這篇文章主要為大家詳細(xì)介紹了SpringBoot如何結(jié)合Vue實(shí)現(xiàn)Python在線調(diào)試器,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2026-01-01

