Spring Swagger常见注解功能介绍

Spring Swagger常见注解功能介绍

@RestController  //它是ResponceBody和Controller注解的合并

@RequestMapping("/api/xxx") //请求URL映射

@Service("xxx") //服务方法注入

@Autowired //装配bean 服务接口

@Target(Element.TYPE) //注解所修饰的对象类型

@Retention(RetentionPolicy.RUNTIME) //注解保留的时间长短

@ConfigurationProperties(prefix = "xxx")//springboot yml配置参数读取

@PostMapping

@PostConstruct //加载时启动

@Transational https://blog..net/nangongwudi/article/details/79150054



 //作用在类上,用来标注该类具体实现内容。表示标识这个类是swagger的资源 。
//可以使用tags()允许您为操作设置多个标签的属性,而不是使用该属性。
@API(tags = {
          
    "xxx" })

@ApiOperation(value=",httpMethod="",notes = "")
@ApiImplicitParams(
  {
          
   @ApiImplicitParam(paramType="form",dataType="",name="",required=true,value="")}
)

//上传文件
upload(ApiParam(name="form",required=true,value="上传文件") @RequestParam(value="file",required=false) MultipartFile f,ht)
经验分享 程序员 微信小程序 职场和发展