swagger UI 不显示 api,而所有配置似乎都是正确的

swagger UI doesn't show apis while all configuration seems to be right

我有一个springboot helloword项目,结构是structure of project

我的 swaggerConfig 是


    @Configuration
    @EnableSwagger2
    public class SwaggerConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                //.enable(false)
                .select()
                .apis(RequestHandlerSelectors.basePackage("org/jayden/swaggertest/controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("SpringBoot and Swagger2")
                .description("desc")
                .termsOfServiceUrl("http://localhost:8080/")
                .version("1.0.0")
                .build();
    }
    }

My controller is:

    @RestController
    @RequestMapping("/user")
    @Api(value = "testApi", tags = "test")
    public class UserController {


    /**
     * @param
     * @return
     */
    @PostMapping(value = "/save")
    @ApiImplicitParam(name = "user", value = "addUser")
    @ApiOperation(value = "addUser", notes = "addUserByParm")
    public String saveUser(){
        return "added";
    }

我用porm.xml:


            <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.7.0</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.7.0</version>
        </dependency>

你能告诉我我犯了什么错误吗? 我从 swagger-ui 那里得到了错误的信息: wrong message from swagger-ui

我在 chrome 中收到来自控制台的错误消息: wrong in chrome console 这是我第一次在 Whosebug 上提问,对于任何不清楚的描述,我们深表歉意。谢谢大家!

你可以试试

RequestHandlerSelectors.basePackage("org/jayden/swaggertest/controller")

而不是

RequestHandlerSelectors.basePackage("org.jayden.swaggertest.controller")