swagger-ui 没有列出任何控制器端点

swagger-ui doesn't list any of the controllers endpoints

我正在尝试将 Swagger 添加到一个非常简单的 hello word Spring-Boot 项目中。

我正在学习本教程:

https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api

这是我的 SwaggerConfig:

@Configuration
@EnableSwagger2
public class SwaggerConfig{

@Bean
public Docket greetingApi() {
    return new Docket(DocumentationType.SWAGGER_2)
            .select()
            .apis(RequestHandlerSelectors.basePackage("com.example.swaggerready"))
            .build()
            .apiInfo(metaData());

}

private ApiInfo metaData() {
    return new ApiInfoBuilder()
            .title("Spring Boot REST API")
            .description("\"Spring Boot REST API for greeting people\"")
            .version("1.0.0")
            .license("Apache License Version 2.0")
            .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0\"")
            .build();
}


}

但是,我得到的结果运行只是第一页,没有任何信息。

如果有人想查看完整代码,可以使用此存储库。 https://github.com/ThadeuFerreira/SpringMicro

在 class SwaggerConfig 中,您需要更改行:

.apis(RequestHandlerSelectors.basePackage("com.example.swaggerready"))

收件人:

.apis(RequestHandlerSelectors.basePackage("com.example.SpringMicro"))