swgger2配置了之后无法访问接口主页。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
4条回答 默认 最新
- 玄尺 2018-08-06 02:24关注
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
swagger配置
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">1、pom依赖<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
</dependency>@EnableSwagger2
@Configuration
public class SwaggerConfig extends WebMvcConfigurationSupport {
@Bean
public Docket createRestApi(PropertiesConfig propertiesConfig) {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo(propertiesConfig))
.select()
.apis(RequestHandlerSelectors. basePackage("com.phicomm.mobile.hermes.hamal.controller"))
.paths(propertiesConfig.isSwaggerEnabled() ? PathSelectors. any() : PathSelectors.none())
.build();
}
private ApiInfo apiInfo(PropertiesConfig propertiesConfig) {
return new ApiInfoBuilder()
.title(propertiesConfig.getSwaggerTitle())
.termsOfServiceUrl(propertiesConfig.getSwaggerServiceUrl())
.contact( new Contact(propertiesConfig.getSwaggerContactName(),
propertiesConfig.getSwaggerContactUrl(),
propertiesConfig.getSwaggerContactEmail()))
.version(propertiesConfig.getSwaggerVersion())
.build();
}
}2、controller上的注解@Api(value = "TestController", description = "test the swagger API TestController")3、具体的接口的注解@ApiOperation(value = "test echo", notes = "直接返回输入参数", response = CommonResponse.class)4、参数的注解@ApiParam(value = "什么参数都可以" ,required=true)5、响应状态码@ApiResponses(value = {@ApiResponse(code = 405, message = "Invalid input", response = PlanSyncBean.class) })结果:http://localhost:8080/swagger-ui.html本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥30 关于用python写支付宝扫码付异步通知收不到的问题
- ¥50 vue组件中无法正确接收并处理axios请求
- ¥15 隐藏系统界面pdf的打印、下载按钮
- ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
- ¥15 基于pso参数优化的LightGBM分类模型
- ¥15 安装Paddleocr时报错无法解决
- ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
- ¥50 分布式追踪trace异常问题
- ¥15 人在外地出差,速帮一点点
- ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改