Swagger 错误 Springboot Could not resolve view with name 'forward:/swagger-ui/index.html'

Swagger error Springboot Could not resolve view with name 'forward:/swagger-ui/index.html'

Springboot 2.5.13,swagger2: 实现“io.springfox:springfox-boot-starter:3.0.0” 实现“io.springfox:springfox-swagger-ui:3.0.0”

运行时错误: 无法解析名称为 'forward:/swagger-ui/index.html'

的视图

解决方案:像这样创建一个 bean:

  @Bean
  public InternalResourceViewResolver defaultViewResolver() {
    return new InternalResourceViewResolver();
  }

来源:https://github.com/springdoc/springdoc-openapi/issues/236