-
-
Notifications
You must be signed in to change notification settings - Fork 589
Property springdoc.swagger-ui.enabled=false throws error when integrating with springmvc(without boot) #1431
Description
Issue
I have integrated springdoc-open-ui 1.6.4 in my spring mvc project that has two services. I want to disable swagger-ui html and added the springdoc.swagger-ui.enabled = false in my property file. But while starting my server it throws below error.
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'swaggerWelcomeWebMvc' defined in URL [jar:file:/Users/apps/keygen/webapps/hello/WEB-INF/lib/springdoc-openapi-ui-1.6.4.jar!/org/springdoc/webmvc/ui/SwaggerWelcomeWebMvc.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springdoc.core.SwaggerUiConfigProperties' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
To Reproduce
Steps to reproduce the behavior:
- pom.xml
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.3.14</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.13.1</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.4</version>
</dependency>
- OpenApi config
@PropertySource({ "classpath:openapiui-swagger.properties" })
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = {
"org.springdoc"
})
@Import({org.springdoc.core.SpringDocConfiguration.class,
org.springdoc.webmvc.core.SpringDocWebMvcConfiguration.class,
org.springdoc.webmvc.core.MultipleOpenApiSupportConfiguration.class,
org.springdoc.webmvc.ui.SwaggerConfig.class,
org.springdoc.core.SwaggerUiConfigProperties.class,
org.springdoc.core.SwaggerUiOAuthProperties.class,
org.springdoc.core.SpringDocConfigProperties.class,
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration.class})
class OpenApiConfig implements WebMvcConfigurer
{
@Bean
public GroupedOpenApi accountApi()
{
return GroupedOpenApi.builder()
.group("v1")
.packagesToScan("rest")
.build();
}
}
- openapiui-swagger.properties
springdoc.swagger-ui.disable-swagger-default-url=true
springdoc.swagger-ui.enabled=false
springdoc.cache.disabled= true
- RestController
@RestController
@RequestMapping( value = "/api", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class RestController
{
@GetMapping("/testopenapi")
public @ResponseBody ResponseEntity<String> testopenapi()
{
return new ResponseEntity<String>("Hello welcome! This is testopenapi controller.",
HttpStatus.OK);
}
}
Expected behavior
- It should start without any error and able to access v3/api-docs and not the swagger-ui/index.html.