Swagger的配置...登录问题

Configuration of Swagger...Problem with Login

在我的 Spring 引导项目中,我创建了 SwaggerConfig class,如下所示:

 @Configuration
@EnableSwagger2
public class SwaggerConfig extends WebMvcConfigurationSupport {

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2).select()
                .apis(RequestHandlerSelectors.basePackage("com.springbootinfluxdb.api.controller"))
                .paths(PathSelectors.any()).build();
    }

    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");

        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
    }

}

而 application.properties 是:

### DATABASE ###
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:postgresql://localhost:5433/test
spring.datasource.username=postgres
spring.datasource.password=postgres

server.port: 8088

当我尝试访问Swagger时,通过地址“localhost:8088/swagger-ui.html#/”出现如下登录界面:

但是我没有登录凭据。 也许,我可以使用每次 运行 项目时出现在 eclipse 输出控制台日志中的密码。

我该如何解决这个问题?? 请帮助我

将此代码添加到您的安全配置中 class:

@Configuration
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers("/v2/api-docs", "/swagger-ui.html");
    }

}