I am adding swagger UI to my Spring boot application. When I try to access the swagger-ui.html. I get the 404 error.
Config class :
@Configuration
public class SwaggerConfig {
@Bean
public OpenAPI springShopOpenAPI() {
return new OpenAPI()
.info(new Info().title("JOYAS-STOCK API Docs")
.description("JOYAS-STOCK REST API documentation")
.version("v1.0.0"));
}
}
appliaction.properties :
#swagger-ui config
springdoc.swagger-ui.path=/swagger-ui
springdoc.swagger-ui.operationsSorter=method
springdoc.swagger-ui.tagsSorter=alpha
pom.xml :
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.13</version>
</dependency>
error message : Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback.
There was an unexpected error (type=Not Found, status=404).
i started with the implementation of the configuration of swagger and apparently it's not working.
click to see screen of the error
Resolved.
the issue was in the versions, they were not compatible! i was using springdoc-openapi v1 with spring boot 3. which is wrong! with spring boot 3, springdoc-openapi v2 should be used. see documentation : https://springdoc.org/v2/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With