【问题标题】:Swagger-ui blank white screen (Spring Boot - Swagger)Swagger-ui空白白屏(Spring Boot-Swagger)
【发布时间】:2023-01-04 22:54:00
【问题描述】:

当我将 Swagger 集成到 spring 项目中时,出现 Swagger 空白页面。 当我尝试使用以下网址访问 Swagger 时,会出现一个空白页面。 http://localhost:8081/swagger-ui.html

pom.xml

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <version>2.7.4</version>
</dependency>
<dependency>
        <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-ui</artifactId>
    <version>1.6.14</version>
</dependency>

主类

@SpringBootApplication
public class ExampleMain {
    public static void main(String[] args) {
        SpringApplication.run(ExampleMain.class, args);
    }
}

应用程序.properties

server.port=8081
springdoc.swagger-ui.path=/swagger-ui.html

安全等级

@Configuration
@EnableWebSecurity
public class SecurityConfig {
    @Bean
    public SecurityFilterChain configure(HttpSecurity http) throws Exception {
        http.authorizeRequests().antMatchers("/**").permitAll();
        return http.build();
    }
}

我该如何解决?

【问题讨论】:

    标签: java spring spring-boot swagger swagger-ui


    【解决方案1】:

    首先,您是否尝试过默认设置?去掉

    springdoc.swagger-ui.path=/swagger-ui.html
    

    和访问

    http://localhost:8081/swagger-ui/index.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-16
      • 2021-08-25
      • 2018-01-27
      • 2021-05-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多