swagger插件结合spring boot非常好用,spring boot开发好接口后添加上swagger插件就可以在页面上看到接口信息,也可以直接测试接口,不管自己用还是给同事看接口都是极好的
1 在这里使用gradle添加swagger依赖
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.6.1'
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.6.1'
2 添加swagger配置代码
package com.example.server;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;