Ich habe eine Spring Boot 1.5.1RELEASE App, die ich Swagger mit verwenden möchte. Ich fügte hinzu, die Abhängigkeiten:Spring Boot und Swagger
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.5.0'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.5.0'compile('org.springframework.boot:spring-boot-devtools')
compile("org.springframework.boot:spring-boot-starter-web:1.5.1RELEASE)
Und dann ein/config Klasse:
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any()).build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("My API Documentation ")
.description("Swagger API Documentation provided for your viewing pleasure")
.version("1.0")
.build();
}
}
Ich habe einen GET Endpunkt
@Api(value = "/words", description = "Words API", produces = "application/json")
@RestController
@RequestMapping("/words")
public class WordsController {
@ApiOperation(value = "getAllWords", nickname = "getAllWords",
response = ResponseEntity.class, httpMethod = "GET")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = ResponseEntity.class),
@ApiResponse(code = 500, message = "Failure")
})
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
public ResponseEntity getAllWords() {
...}
Aber wenn ich meine api in http://localhost:3000/swagger-ui.html
zugreifen (Ich habe meine Server konfiguriert, um auf Port 3000 zu laufen Ich bekomme nur die grüne Prahlerei bar
ich dieses Gebäude mehr Tutorials aus, aber ich kann nicht sehen, warum ist meine Swagger Dokumentation nicht
I Ich denke, ich habe es behoben, indem ich meine SwaggerConfig in meine Hauptklasse verschoben habe. Aus irgendeinem Grund wird diese @Configuration nicht abgeholt – sonoerin