我想使用Swagger 2.0和Spring Boot RESTful web服务来生成文档。我已经搜索了相当多的答案。基本上我有一个控制器的Spring Boot项目,我想记录API的。我在我的POM文件中设置了以下依赖项。Swagger Spring Boot的REST API文档
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.5.0</version>
</dependency>
这是我扬鞭配置类与@Configuration和@ EnableSwagger2:
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api(){
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.regex("/api/.*"))
.build()
.apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("My application title")
.description("This is a test of documenting EST API's")
.version("V1.2")
.termsOfServiceUrl("http://terms-of-services.url")
.license("LICENSE")
.licenseUrl("http://url-to-license.com")
.build();
}
}
从我所聚集在阅读了几个其他的答案在这里,在这一点上,我应该能够看到一些网址,如http://myapp/v2/api-docs或http://localhost:8080/myapp/api-docs我做了一个假设,上面的URL的“myapp”部分引用了我的主要驻留的类的名称(这是否正确)?我也尝试过使用端口8080和端口80,而底线是我看不到其他网站无法访问的东西。我已经看过提供的答案here和here但是我没有取得任何成功。任何帮助将不胜感激,先谢谢你。
试试这个:HTTP://本地主机: 8080/myapp/swagger-ui.html –