In my Spring Boot project I created the SwaggerConfig class like this:
@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/");
}
}
And the application.properties is:
### 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
When I try to access the Swagger, through the address "localhost: 8088 / swagger-ui.html # /" the following login interface appears:
But I don't have the login credentials. Perhaps, I could use a password that appears in the eclipse output console logs every time they run the project.
How can I solve the problem?? Please help me
Add this code to your security config class:
@Configuration
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/v2/api-docs", "/swagger-ui.html");
}
}