将 Spring Boot 升级到 2.7.0 - 无法启动 bean 'documentationPluginsBootstrapper

Dib*_*bya 8 java spring-boot

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

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

Springfox: //swagger 编译“io.springfox:springfox-swagger2:2.9.2” 编译“io.springfox:springfox-swagger-ui:2.9.2”

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

任何领导都非常感谢解决这个问题。

小智 5

在application.properties中

spring.mvc.pathmatch.matching-strategy= ANT_PATH_MATCHER
Run Code Online (Sandbox Code Playgroud)


Ary*_*ari 3

如果您使用的是 spring-boot 2.7.x 版本,springfox 和执行器使用此依赖项(我不知道它是否适合您的情况,在我这样做时,spring-boot 2.7.x 版本) 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>
    
    Run Code Online (Sandbox Code Playgroud)
  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("/");
     }
    
    Run Code Online (Sandbox Code Playgroud)
  3. 然后

如果您正在使用 application.properties

spring.mvc.pathmatch.matching-strategy= ANT_PATH_MATCHER
Run Code Online (Sandbox Code Playgroud)

如果您正在使用 application.yml

    spring:
      #Use this to befriend spring-boot-starter-actuator & springfox-boot-starter
       mvc:
         pathmatch:
           matching-strategy: ANT_PATH_MATCHER
Run Code Online (Sandbox Code Playgroud)