添加对swagger2的支持
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!--根据代码自动生成文档-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
|
||||
+2
@@ -4,9 +4,11 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@SpringBootApplication
|
||||
@RestController
|
||||
@EnableSwagger2//默认的访问地址是/swagger-ui.html
|
||||
public class BootStarterSecurityDemoApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
+2
@@ -2,6 +2,7 @@ package com.micro.fast.security.demo.controller;
|
||||
|
||||
import com.micro.fast.security.demo.pojo.DeferredResultHolder;
|
||||
import com.micro.fast.security.demo.pojo.MockQueue;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -50,6 +51,7 @@ public class AsyncController {
|
||||
* 使用DeferredResult的方式处理复杂的请求
|
||||
*/
|
||||
@GetMapping("/deferred")
|
||||
@ApiOperation(value = "复杂的异步处理")
|
||||
public DeferredResult<String> deferredResult(){
|
||||
logger.info("主线程开始");
|
||||
//只有result中被填入值的时候才会被作为结果进行返回,不然主线程会结束,但是deferredResult的线程并不会结束
|
||||
|
||||
+3
@@ -1,6 +1,8 @@
|
||||
package com.micro.fast.security.demo.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.hibernate.validator.constraints.*;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
@@ -50,6 +52,7 @@ public class User {
|
||||
// @Future 日期必须是未来的日期
|
||||
@Max(value = 1)//最大值 小于等于 不能注解在字符串上
|
||||
@Min(2) //最小值 大于等于 不能注解在字符串上
|
||||
@ApiModelProperty(value = "用户的出生日期")
|
||||
private Date birthday;
|
||||
|
||||
public User() {
|
||||
|
||||
Reference in New Issue
Block a user