I hope you are all doing well. I am trying to enable the swagger in my spring boot and somehow I can not get it working. I took all the steps which I should have, it is really frustrating now to stick at it for a day. Here are the details.
- Added Dependencies
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
- Enable the swagger annotation
@EnableSwagger2
- Create a bean with Docket Object to scan
@Bean
public Docket swaggerApi() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("ml.XXXXXXXX"))
.paths(PathSelectors.any())
.build()
.apiInfo(new ApiInfoBuilder().version("v1")
.title("Account Service API")
.description("Documentation Account Service API v1").build());
}
My servlet context path is
server:
servlet:
context-path: /account
I have tried every possible URL of swagger like http://localhost:8080/swagger-ui.html, http://localhost:8080/account/swagger-ui.html, http://localhost:8080/account/v2/api-docs. None of this is working. Could you please let me know if I am missing anything or doing wrong. I would really appreciate it.
Thanks ~~