美文网首页Java 杂谈
五,Spring Boot基于MySQL,MyBatis配置Sw

五,Spring Boot基于MySQL,MyBatis配置Sw

作者: Wocus | 来源:发表于2018-09-25 15:25 被阅读1次
    此配置有助于接口测试方面的

    1.gradle配置

    compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.5.0'
    compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.5.0'
    

    2.添加类文件

    @Configuration
    @EnableSwagger2
    public class SwaggerConfig {
        @Bean
        public Docket createRestApi() {
            return new Docket(DocumentationType.SWAGGER_2)
                    .select()
                    .apis(RequestHandlerSelectors.basePackage("com.example.demo1.controller"))
                    .paths(PathSelectors.any())
                    .build()
                    .apiInfo(apiInfo());
        }
        private ApiInfo apiInfo(){
            return new ApiInfoBuilder()
                    .title("API Title")
                    .description("API Description")
                    .termsOfServiceUrl(" API terms of service")
                    .version("1.0.0")
                    .build();
        }
    }
    

    3.直接访问 localhost:8080/swagger-ui.html

    image.png

    相关文章

      网友评论

        本文标题:五,Spring Boot基于MySQL,MyBatis配置Sw

        本文链接:https://www.haomeiwen.com/subject/ohrloftx.html