0
我有一个spring引导1.5.1RELEASE应用程序,我试图使用Swagger。我加了依赖性:Spring Boot和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)
然后A /配置类:
@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();
}
}
我有一个GET端点
@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() {
...}
但是,当我在http://localhost:3000/swagger-ui.html
访问我的API(我有我服务器配置为在端口3000上运行我只能看到绿色的招牌吧
我建立这一关几个教程,但我不明白为什么我的文档扬鞭没有被呈现
我认为我通过将我的SwaggerConfig移动到我的主类中来修复它,所以出于某种原因,这个@Configuration没有被拾取 – sonoerin