最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

springboot2.6.7集成springfox3.0.0的示例代碼

 更新時間:2024年04月29日 09:21:48   作者:阿湯哥  
這篇文章主要介紹了springboot2.6.7集成springfox3.0.0的示例代碼,本文通過示例代碼給大家介紹的非常詳細,感興趣的朋友跟隨小編一起看看吧

springboot2.6.7集成springfox3.0.0 

1. pom配置

<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>3.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>3.0.0</version>
</dependency>

2. 增加swagger自動配置類

import org.springframework.context.annotation.Configuration;
import springfox.documentation.oas.annotations.EnableOpenApi;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.OAS_30)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.controller"))
                .build();
    }
	private SecurityScheme apiKey() {
        return new ApiKey("JWT", "Authorization", "header");
    }
}

此時嘗試啟動應(yīng)用會提示一下錯誤:

Caused by: org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException

Caused by: 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)
        at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
        at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
        at java.lang.Iterable.forEach(Iterable.java:75)
        at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
        at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:175)
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:155)
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:97)
        at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:174)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5221)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        ... 44 more
    Caused by: java.lang.NullPointerException
        at springfox.documentation.spring.web.WebMvcPatternsRequestConditionWrapper.getPatterns(WebMvcPatternsRequestConditionWrapper.java:56)
        at springfox.documentation.RequestHandler.sortedPaths(RequestHandler.java:113)
        at springfox.documentation.spi.service.contexts.Orderings.lambda$byPatternsCondition$3(Orderings.java:89)
        at java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:469)
        at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
        at java.util.TimSort.sort(TimSort.java:234)
        at java.util.Arrays.sort(Arrays.java:1512)
        at java.util.ArrayList.sort(ArrayList.java:1464)
        at java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:387)
        at java.util.stream.Sink$ChainedReference.end(Sink.java:258)
        at java.util.stream.Sink$ChainedReference.end(Sink.java:258)
        at java.util.stream.Sink$ChainedReference.end(Sink.java:258)
        at java.util.stream.Sink$ChainedReference.end(Sink.java:258)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:483)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
        at springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider.requestHandlers(WebMvcRequestHandlerProvider.java:81)
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
        at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.withDefaults(AbstractDocumentationPluginsBootstrapper.java:107)
        at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.buildContext(AbstractDocumentationPluginsBootstrapper.java:91)
        at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.bootstrapDocumentationPlugins(AbstractDocumentationPluginsBootstrapper.java:82)
        at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:100)
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
        ... 61 more

3. 配置修改

spring:
  mvc:
    pathmatch:
      matching-strategy: ant_path_matcher

4. 自動配置類增加以下內(nèi)容

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

參考

Spring Boot 2.6.0 / Spring fox 3 - Failed to start bean ‘documentationPluginsBootstrapper

到此這篇關(guān)于springboot2.6.7集成springfox3.0.0的文章就介紹到這了,更多相關(guān)springboot集成springfox3.0.0內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • java實現(xiàn)代碼統(tǒng)計小程序

    java實現(xiàn)代碼統(tǒng)計小程序

    這篇文章主要為大家詳細介紹了java實現(xiàn)代碼統(tǒng)計小程序,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-09-09
  • Mybatis中typeAliases的使用

    Mybatis中typeAliases的使用

    這篇文章主要介紹了Mybatis中typeAliases的使用,需要的朋友可以參考下
    2017-08-08
  • 基于Java實現(xiàn)掃碼登錄的示例代碼

    基于Java實現(xiàn)掃碼登錄的示例代碼

    相信大家對二維碼都不陌生,生活中到處充斥著掃碼登錄的場景,如登錄網(wǎng)頁版微信、支付寶等。本文將利用Java實現(xiàn)一個簡易版掃碼登錄的 Demo,需要的可以參考一下
    2022-04-04
  • springboot枚舉類型傳遞的步驟

    springboot枚舉類型傳遞的步驟

    這篇文章主要介紹了springboot枚舉類型傳遞的步驟,幫助大家更好的理解和學(xué)習(xí)使用springboot,感興趣的朋友可以了解下
    2021-04-04
  • 解決java數(shù)值范圍以及float與double精度丟失的問題

    解決java數(shù)值范圍以及float與double精度丟失的問題

    下面小編就為大家?guī)硪黄鉀Qjava數(shù)值范圍以及float與double精度丟失的問題。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-06-06
  • Maven打jar包的三種方式(小結(jié))

    Maven打jar包的三種方式(小結(jié))

    這篇文章主要介紹了Maven打jar包的三種方式,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • SpringCloud之Feign遠程接口映射的實現(xiàn)

    SpringCloud之Feign遠程接口映射的實現(xiàn)

    這篇文章主要介紹了SpringCloud之Feign遠程接口映射的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • Eclipse可視化插件WindowBuilder的安裝方法

    Eclipse可視化插件WindowBuilder的安裝方法

    這篇文章主要介紹了Eclipse可視化插件WindowBuilder的安裝方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-06-06
  • java中的日期時間類Date和SimpleDateFormat

    java中的日期時間類Date和SimpleDateFormat

    這篇文章主要介紹了java中的日期時間類Date和SimpleDateFormat,Date類的對象在Java中代表的是當前所在系統(tǒng)的此刻日期時間,說白了就是你計算機上現(xiàn)實的時間,需要的朋友可以參考下
    2023-09-09
  • idea 打包的jar運行報

    idea 打包的jar運行報 "XXX中沒有主清單屬性"

    這篇文章主要介紹了idea 打包的jar運行報 "XXX中沒有主清單屬性",文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-03-03

最新評論

罗定市| 杂多县| 沙坪坝区| 沁阳市| 广东省| 嘉兴市| 苍山县| 正镶白旗| 苗栗市| 松潘县| 伊金霍洛旗| 武义县| 沂南县| 方正县| 桓台县| 徐汇区| 旬阳县| 南岸区| 荃湾区| 阿瓦提县| 古蔺县| 木兰县| 启东市| 阿巴嘎旗| 开江县| 景谷| 连江县| 疏勒县| 上犹县| 龙川县| 静海县| 随州市| 姚安县| 黑河市| 东安县| 丰都县| 吉水县| 永春县| 贵溪市| 南昌市| 黄石市|