spring boot框架常用的一些玩意儿

后端

A. maven管理依赖 聚合项目 

B. 基础框架 spring boot

C. 引入spring cloud微服务提供 版本netfilx

        1.注册中心使用nacos

                Nacos Docker 快速开始

        2.接口调用feign

                Spring Cloud OpenFeign

        3.熔断Hystrix Htxon.SR3

                快速开始 · Hystrix Document

        4.搜索引擎 es7

                Welcome to Elastic Docs | Elastic

        5.接口文档swagger

           添加依赖

<!-- swagger-ui -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.9.2</version>
</dependency>
<!-- swagger2 -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.9.2</version>
</dependency>

              添加配置类

@EnableSwagger2
@Configuration
public class SwaggerConfig {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                // 自行修改为自己的包路径
                .apis(RequestHandlerSelectors.basePackage("com.zhanggm.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("深度应用后台api接口文档")
                .description("restful 风格接口")
                .version("1.0")
                .build();
    }
}

                访问地址:http://ip:port/swagger-ui.html

                注解使用说明

@Api 类说明

@Api:用在请求的类上,说明该类的作用
    tags="说明该类的作用"
    value="该参数没什么意义,所以不需要配置"
@Api("APP用户注册Controller")
public class UserController {
}
属性名称数据类型默认值说明
valueString“”隐式设置操作的标记,遗留支持(读取 description)
tagsString[]“”对接口进行分组
producesString“”
consumesString“”采用逗号分隔的 content types,例如: application/json,application/xml 会接收JSON和XML的输入
protocolsString“”采用逗号分隔的可用协议,例如:http,https,ws,wss
authorizationsAuthorization[]“”授权列表
hiddenbooleanfalse隐藏此资源下的操作, 和 @ApiOperation 注解中的 hidden 组合使用可以隐藏改接口

@ApiOperation 方法说明

@ApiOperation:"用在请求的方法上,说明方法的作用"
    value="说明方法的作用"
    notes="方法的备注说明"
@Api("APP用户注册Controller")
public class UserController {
    @ApiOperation(value="用户注册",notes="手机号、密码都是必输项,年龄随边填,但必须是数字")
    @RequestMapping("register")
    public Object register(){
        
    }
}
属性名称数据类型默认值说明
valueString接口简要说明,120字符或更少
notesString“”接口详细描述
tagsString[]“”tag 列表,可用于按自愿或任何其它限定符对操作进行逻辑分组
responseClass<?>Void.class接口返回类型
responseContainerString“”声明包装响应的容器。有效值为 List,Set,Map,任何其它值都将被忽略
responseReferenceString“”指定对响应类型的引用,本地/远程引用,并将覆盖任何其它指定的response()类
httpMethodString“”请求方式:“GET”, “HEAD”, “POST”, “PUT”, “DELETE”, “OPTIONS” and “PATCH”,如果未指定则使用除"PATH"之外的其它所有
nicknameString“”第三方工具使用operationId来唯一表示此操作
producesString“”采用逗号分隔的 content types 类型的返回数据,例如:application/json,application/xml
consumesString“”采用逗号分隔的 content types 类型的入参数据类型,例如:application/json,application/xml
protocolsString“”指定协议类型:http,https,ws,wss,多个协议使用逗号进行分隔
authorizationsAuthorization[]@Authorization(value = “”)获取此操作的授权列表
hiddenbooleanfalse是否隐藏操作列表中的操作
responseHeadersResponseHeader[]@ResponseHeader(name = “”, response = Void.class)指定 response header 信息列表
codeint200HTTP返回状态码
extensionsExtension[]@Extension(properties = @ExtensionProperty(name = “”, value = “”))可选的扩展数组

@ApiImplicitParams**参数说明

用在请求的方法上,包含一组参数说明

 @ApiImplicitParams:用在请求的方法上,包含一组参数说明
      @ApiImplicitParam:用在 @ApiImplicitParams 注解中,指定一个请求参数的配置信息       
          name:参数名
          value:参数的汉字说明、解释
          required:参数是否必须传
          paramType:参数放在哪个地方
              · header --> 请求参数的获取:@RequestHeader
              · query --> 请求参数的获取:@RequestParam
              · path(用于restful接口)--> 请求参数的获取:@PathVariable
             · body(不常用)
             · form(不常用)    
         dataType:参数类型,默认String,其它值dataType="Integer"       
         defaultValue:参数的默认值
@Api("APP用户注册Controller")
public class UserController {
    @ApiImplicitParams({
    @ApiImplicitParam(name="mobile",value="手机号",required=true),
    @ApiImplicitParam(name="password",value="密码",required=true),
    @ApiImplicitParam(name="age",value="年龄",required=true,paramType="form",dataType="Integer")
	})
    @RequestMapping("register")
    public Object register(){
        
    }
}
属性名称数据类型默认值说明
nameString“”参数名称,参数名称将从 filed/method/parameter 名称中派生, 但你可以覆盖它,路径参数必须始终命名为它们所代表的路径部分
valueString“”参数简单描述
defaultValueString“”描述参数默认值
allowableValuesString“”可接收参数值限制,有三种方式,取值列表,取值范围
requiredbooleanfalse是否为必传参数, false:非必传; true:必传
accessString“”参数过滤,请参阅:io.swagger.core.filter.SwaggerSpecFilter
allowMultiplebooleanfalse指定参数是否可以通过多次出现来接收多个值
hiddenbooleanfalse隐藏参数列表中的参数
exampleString“”非请求体(body)类型的单个参数示例
examplesExample@Example(value = @ExampleProperty(mediaType = “”, value = “”)) 参数示例,仅适用于请求体类型的请求
typeString“”添加覆盖检测到类型的功能
formatString“”添加提供自定义format格式的功能
allowEmptyValuebooleanfalse添加将格式设置为空的功能
readOnlybooleanfalse添加被指定为只读的能力
collectionFormatString“”添加使用 array 类型覆盖 collectionFormat 的功能

@ApiResponses方法返回说明

@ApiResponses:用于请求的方法上,表示一组响应
     @ApiResponse:用在@ApiResponses中,一般用于表达一个错误的响应信息
         code:数字,例如400
         message:信息,例如"请求参数没填好"
         response:抛出异常的类
@Api("APP用户注册Controller")
public class UserController {
    @ApiResponses({
     @ApiResponse(code=400,message="请求参数没填好"),
     @ApiResponse(code=404,message="请求路径没有或页面跳转路径不对")
	})
    @RequestMapping("register")
    public Object register(){
        
    }
}
属性名称数据类型默认值说明
codeint响应的HTTP状态码
messageString伴随响应的人类可读的消息
responseClass<?>Void.class用于描述消息有效负载的可选响应类,对应于响应消息对象的 schema 字段
referenceString“”指定对响应类型的引用,指定的应用可以使本地引用,也可以是远程引用, 将按原样使用,并将覆盖任何指定的response()类
responseHeadersResponseHeader[]@ResponseHeader(name = “”, response = Void.class)可能响应的 header 列表
responseContainerString“”声明响应的容器,有效值为List,Set,Map,任何其他值都将被忽略

@ApiModel 模型说明

@ApiModel:用于响应类上,表示一个返回响应数据的信息
             (这种一般用在post创建的时候,使用@RequestBody这样的场景,
             请求参数无法使用@ApiImplicitParam注解进行描述的时候)
     @ApiModelProperty:用在属性上,描述响应类的属性
 @ApiModel(description= "返回响应数据")
 public class RestMessage implements Serializable{
     @ApiModelProperty(value = "是否成功")
     private boolean success=true;
     @ApiModelProperty(value = "返回对象")
     private Object data;
     @ApiModelProperty(value = "错误编号")
     private Integer errCode;
     @ApiModelProperty(value = "错误信息")
     private String message;
     /* getter/setter */
 }
属性名称数据类型默认值说明
valueString类名为模型提供备用名称
descriptionString“”提供详细的类描述
parentClass<?>Void.class为模型提供父类以允许描述继承关系
discriminatoryString“”支持模型继承和多态,使用鉴别器的字段的名称,可以断言需要使用哪个子类型
subTypesClass<?>[]{}从此模型继承的子类型数组
referenceString“”指定对应类型定义的引用,覆盖指定的任何其他元数据

@ApiModelProperty

属性名称数据类型默认值说明
valueString“”属性简要说明
nameString“”运行覆盖属性的名称。重写属性名称
allowableValuesString“”限制参数可接收的值,三种方法,固定取值,固定范围
accessString“”过滤属性,参阅:io.swagger.core.filter.SwaggerSpecFilter
notesString“”目前尚未使用
dataTypeString“”参数的数据类型,可以是类名或原始数据类型,此值将覆盖从类属性读取的数据类型
requiredbooleanfalse是否为必传参数,false:非必传参数; true:必传参数
positionint0允许在模型中显示排序属性
hiddenbooleanfalse隐藏模型属性,false:不隐藏; true:隐藏
exampleString“”属性的示例值
readOnlybooleanfalse指定模型属性为只读,false:非只读; true:只读
referenceString“”指定对应类型定义的引用,覆盖指定的任何其他元数据
allowEmptyValuebooleanfalse允许传空值,false:不允许传空值; true:允许传空值

        6.sql监控

                SQL监控_HaoFather_father的博客-优快云博客

        7.安全登录security

                Spring——Security安全框架使用详解(基于内存认证)_专注写bug的博客-优快云博客_security安全框架

        8.缓存机制redis 限流

                Redis 教程 | 菜鸟教程

        9.网关 gateway

                

        10.全局令牌token采用jwt生成 

        11.阿里云短信集成

        12.aop+Kafka日志存储

        13.七牛云oss文件存储

             Spring Boot集成七牛云对象存储oss_dreaming9420的博客-优快云博客_springboot集成七牛云

        14.quartz定时任务

前端 

vue vuex element-ui axios echarte图表 quill富文本

api 公共模块

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值