您的位置:首页 > 教程文章 > 编程开发

解决swaggerUI页面没有显示Controller方法的坑

:0 :2021-10-19 22:37:08

swaggerUI页面没有显示Controller方法的坑
最近用springboot搭建一个配置系统,使用swagger,但是启动访问页面发现以下问题。
研究发现少了以下配置,这两行很重要:
全部代码如下:
@Configuration
@EnableSwagger2
public class Swagger2 {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.config"))
                .paths(PathSelectors.any())
                .build();
    }
 
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("配置系统API")
                .version("1.0")
                .description("钟渊-2019-6-15")
                .build();
    }
}
再次启动正常:
Swagger2构建RESTful API文档遇到的坑
@ApiImplicitParam(name = "id", value = "用户ID",required = true, dataType = "Long")
这个里面少了一个参数:paramType="path",否则无法从路径中获得id值。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持无名。

Java搭建简单Netty开发环境入门教程
Springboot连接数据库及查询数据完整流程

同类资源