I am using springboot with jersey as restful API. Now I want to integrate swagger2 into my project but it doesn't work. When I run my application and access http://localhost:8080/swagger-ui.html. I got the swagger web page but no api is showing(see below image). It seems that swagger didn't find my api classes.
Below is the dependencies I added.
compile "io.springfox:springfox-swagger2:2.5.0"
compile 'io.springfox:springfox-swagger-ui:2.5.0'
Below is my application class:
@SpringBootApplication
@EnableSwagger2
@EnableAutoConfiguration
@Configuration
@ComponentScan(value = "com.ticket.api")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public Docket documentation() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.lenovo.ticket.api"))
.paths(PathSelectors.any())
.build().pathMapping("/")
.useDefaultResponseMessages(false);
}
@Bean
UiConfiguration uiConfig() {
return UiConfiguration.DEFAULT;
}
}
Below is my jersey config class:
@Configuration
@ApplicationPath("/ticket")
public class JerseyConfig extends ResourceConfig {
public JerseyConfig(){
register(Helloworld.class);
}
}
Jersey isn't supported, please refer to this answer. Given that the answer comes from SpringFox library's author, I'd say the info is solid.