【问题标题】:Upgraded Spring Boot to 2.7.0- Failed to start bean 'documentationPluginsBootstrapper将 Spring Boot 升级到 2.7.0 - 无法启动 bean 'documentationPluginsBootstrapper
【发布时间】:2022-07-19 04:31:21
【问题描述】:

升级 Springboot 版本- 2.7.0 ext { springBootVersion = '2.7.0' wsdl2javaVersion='0.10' cxfVersion='3.4.3' }

云版本:ext { set('springCloudVersion', '2021.0.3') }

Springfox: //swagger compile "io.springfox:springfox-swagger2:2.9.2" compile "io.springfox:springfox-swagger-ui:2.9.2"

出现错误:org.springframework.context.ApplicationContextException:无法启动 bean 'documentationPluginsBootstrapper';嵌套异常是 java.lang.NullPointerExceptionclass

非常感谢任何领导解决此问题。

【问题讨论】:

标签: java spring-boot


【解决方案1】:

如果您使用的是 spring-boot 版本 2.7.x,springfox 和执行器使用此依赖项(我不知道它是否适用于您的情况,当时我正在执行此操作,spring-启动 2.7.1)

  1. 在 pom.xml 中

     <!-- API documentation. Refer the link http://springfox.github.io/springfox/docs/2.7.0/#introduction -->
     <dependency>
         <groupId>io.springfox</groupId>
         <artifactId>springfox-swagger2</artifactId>
         <version>2.7.0</version>
     </dependency>
    
  2. 然后在SwaggerConfig配置类中

     /* .pathMapping("/") can resolve the conflict between actuator and springfox */
     @Bean
     public Docket api() {
         return new Docket(DocumentationType.SWAGGER_2)
             .select()
             .apis(RequestHandlerSelectors.any())
             .paths(PathSelectors.any())
             .build()
             .pathMapping("/");
     }
    
  3. 然后

如果您使用的是 application.properties

spring.mvc.pathmatch.matching-strategy= ANT_PATH_MATCHER

如果您使用的是 application.yml

    spring:
      #Use this to befriend spring-boot-starter-actuator & springfox-boot-starter
       mvc:
         pathmatch:
           matching-strategy: ANT_PATH_MATCHER

【讨论】:

    猜你喜欢
    • 2021-01-07
    • 2019-09-29
    • 2021-12-30
    • 1970-01-01
    • 2022-06-11
    • 2020-09-15
    • 1970-01-01
    • 2018-10-31
    • 2022-01-23
    相关资源
    最近更新 更多