Spring Boot 整合Swagger2
2021-03-06 02:29
标签:ali url return ase XML inf sele 导入 算法 依赖导入 编写配置类 Controller层 pojo 地址:http://localhost:8080/swagger-ui.html Spring Boot 整合Swagger2 标签:ali url return ase XML inf sele 导入 算法 原文地址:https://www.cnblogs.com/zero-vic/p/14313187.htmlSpring Boot 整合Swagger2
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api(){
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.apis(RequestHandlerSelectors.basePackage("com.xy.video.controller"))
.build()
.apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("毕设测试Swagger")
.contact(new Contact("念月",
"https://www.cnblogs.com/zero-vic/",
"1623272666@qq.com"))
.description("喜欢就去给她说吧,不要给自己留遗憾了!")
.version("5.2.0")
.termsOfServiceUrl("http://baidu.com")
.license("LICENSE")
.licenseUrl("链接地址")
.build();
}
}
@RestController
@Api(tags = "用于用户管理的接口")
public class UserController {
@Autowired
private UserService userService;
@GetMapping("user")
@ApiOperation(value = "用户查询所有接口",notes = "分页查询用户信息")
@ApiResponses({
@ApiResponse(code = 200, message = "操作成功"),
@ApiResponse(code = 500, message = "操作失败,根据msg查看具体的错误信息")
})
public Map
@ApiModel
public class User implements Serializable {
/**
* id(雪花算法生成)
*/
@ApiModelProperty(value = "用户ID",name = "id",dataType = "long",required = true)
private Long id;
文章标题:Spring Boot 整合Swagger2
文章链接:http://soscw.com/index.php/essay/60663.html