swagger(前言技术)

news2024/9/29 15:22:58

目录

一、swagger简介

1.前后端分离的特点

2.在没有swagger之前 

3.swagger的作用

4.swagger的优点

二、swagger入门

1.新建springboot项目

 2.集成swagger

3.开发一个controller用于测试

5.启动服务,验证集成效果

三、swagger常用注解 

四、swagger使用综合案例 

五、swagger2整合会议OA项目


一、swagger简介

1.前后端分离的特点

前后端分离是的前端与后端之间的职责更加明确

后台: 负责业务处理

前端: 负责显示逻辑

在这种情况下,前端和后端可以分别交付给专业的开发人员去做,所以是必须要定义前后端直接的对接接口,否则各自为是则项目无法集成,这时就需要一个文档来定义统一的接口。

2.在没有swagger之前 

在没有swagger之间,我们可以使用word,excel等功能来书写接口定义文档,但又有一个弊端,即:

在接口发送改变时需要及时的同步接口文档,否则实际的接口与接口文档不相符,则接口文件就失去了

作用,甚至会起到反作用。

3.swagger的作用

根据在代码中使用自定义的注解来生成接口文档,这个在前后端分离的项目中很重要。这样做的好处是在开发接口时可以通过swagger将接口文档定义好,同时也方便以后的维护。

4.swagger的优点

号称时最流行的API框架

接口文档在线生成,避免同步的麻烦

可以支持在线对接口执行测试                注意:不需要postman或者Eolink

支持多语言

二、swagger入门

1.新建springboot项目

使用集成开发工具创建一个springboot工程

 2.集成swagger

1.pom.xml

<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>

2.编写swagger配置类

package com.jwj.swagger.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author 敢敢
 * @site www.javajwj.com
 * @company xxx公司
 * @create  2023-01-15 15:32
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
                .paths(PathSelectors.ant("/**")) //项目名
                .build();

    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("SwaggerDemoAPIDOC")
                .description("SwaggerDemoAPIDOC")
                .version("1.0")
                .termsOfServiceUrl("https://www.baidu.com").build();
    }
}

注意:Springboot与swagger2的版本对应关系,否则项目是启动不成功的,这里的版本对应关系如下:

最终的pom.xml代码如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.11</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.jwj</groupId>
    <artifactId>swagger</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>swagger</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>5.3.24</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

 这里就说明启动成功了。这里我就不运行了。

3.开发一个controller用于测试

package com.jwj.swagger.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 敢敢
 * @site www.javajwj.com
 * @company xxx公司
 * @create  2023-01-15 15:32
 */
@Api(tags = "swagger入门案例")
@RestController
@RequestMapping("/swagger")
public class HelloController {
    @ApiOperation("打招呼的接口")
    @GetMapping("/hello")
    public Map hello(){
        Map map = new HashMap();
        map.put("code",200);
        map.put("msg","操作成功!!!");
        return map;
    }
}

5.启动服务,验证集成效果

服务启动后,访问:http://localhost:8080/swagger-ui.html

三、swagger常用注解 

注解位置作用参数
@Api标识这个类是swagger的资源tags:说明该类的作用,参数是个数组,可 以填多个。
value="该参数没什么意义,在UI界面上不显示,所以不用配置"
description = "用户基本信息操作"
@ApiOperation方法表示一个http请求的操作value="方法的用途和作用"
notes="方法的注意事项和备注"
tags:说明该方法的作用,参数是个数组,可以填多 个。
格式:tags={"作用1","作用2"}
@ApiParam方法,参数对参数使用说明(如:说明 或是否必填等)value="用户名" 描述参数的意义
name="name" 参数的变量名
required=true 参数是否必选
@ApiModel表示对类进行说明,用于参 数用实体类接收,一般用在 DTO上description="描述实体的作用"
@ApiModelProperty方法,字段表示对model属性的说明value="用户名" 描述参 数的意义
name="name" 参数的变量名
required=true 参数是否必选
@ApiIgnore类,方法,参数表示这个方法或者类被忽略
@ApiImplicitParams方法包含多@ApiImplicitParam
@ApiImplicitParam方法表示单独的请求参数name="参数名称"
value="参数说明"
dataType="数据类型"
paramType="query" 表示参数放在哪里
defaultValue="参数的默认值"
required="true" 表示参数是否必须传

paramType="query"的解释如下

header 请求参数的获取:@RequestHeader
query 请求参数的获取:@RequestParam
path(用于restful接口) 请求参数的获取:@PathVariable
body(不常用)
form(不常用)

更全面的信息可以参考官方说明文档:

swagger-annotations 1.3.10 API

四、swagger使用综合案例 

SwaggerController.java 

package com.jwj.swagger.controller;

import com.jwj.swagger.model.User;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author小李飞刀
 * @site www.javaxl.com
 * @company xxx公司
 * @create  2023-01-06 19:26
 */
@RestController
@RequestMapping("/swagger/api")
@Api(tags = "swagger所有注解的讲解")
public class SwaggerController {


    @ApiOperation(value = "欢迎信息")
    @GetMapping("/hello")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", dataType = "string", paramType = "query", required = true),
            @ApiImplicitParam(name = "msg", value="消息", dataType = "string", paramType = "query", required = true)
    })
    public Object hello(String name, String msg) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("msg", "操作成功");
        map.put("info",name+":"+msg);
        return map;
    }

    @PostMapping("/register")
    @ApiOperation("注册用户接口")
    @ApiResponses({
            @ApiResponse(code = 5001001,message = "错误1"),
            @ApiResponse(code = 5001002,message = "错误2"),
            @ApiResponse(code = 5001003,message = "错误3")
    })
    public Object register(User user) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 5001002);
        map.put("msg", "操作成功");
        map.put("info",user);
        return map;
    }

    @PutMapping("/edit")
    @ApiOperation("修改用户信息")
    public Object edit(@RequestBody User user) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("msg", "操作成功");
        map.put("info",user);
        return map;
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除用户")
    @ApiImplicitParam(name = "id", value="用户ID", dataType = "string", paramType = "path", required = true)
    public Object delete(@PathVariable("id") String id) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("msg", "操作成功");
        map.put("info",id);
        return map;
    }
}

user.java

package com.jwj.swagger.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel(description = "用户信息")
public class User {

    @ApiModelProperty(value = "用户名", name="name", required = true)
    private String name;

    @ApiModelProperty(value = "密码", name="passwd", required = true)
    private String passwd;

}

我们要导入lombok依赖

<dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

效果如图所示:

五、swagger2整合会议OA项目

在前面有导入swagger,pom依赖,编写swagger配置类

 1.最终的pom依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.7</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.jwj</groupId>
    <artifactId>minoa</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>minoa</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
        <fastjson.version>1.2.70</fastjson.version>
        <jackson.version>2.9.8</jackson.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.2.1</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.44</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>${fastjson.version}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.2</version>
                <dependencies>
                    <!--使用Mybatis-generator插件不能使用太高版本的mysql驱动 -->
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>${mysql.version}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <overwrite>true</overwrite>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

2.注意:在SpringBoot(2.7.7)版本与swagger2 (2.9.2) 的版本不兼容,需要添加application.yml相关配置

3.application.yml

spring:
  mvc:
    pathmatch:
      matching-strategy: ant_path_matcher

4.web层接口服务提供

package com.jwj.minoa.wxcontroller;

import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "会议OA接口开发测试")
@RestController
public class HelloController {
    @GetMapping("/hello")
    public String hello(){
        return "hello";
    }
}
@Api(tags = "会议OA小程序接口列表")
@RestController
@RequestMapping("/wx/home")
public class WxHomeController {
    @Autowired
    private InfoMapper infoMapper;

    @ApiOperation("会议OA首页数据加载")
    @GetMapping("/index")
    public Object index(@RequestBody Info info) {
        List<Info> infoList = infoMapper.list(info);
        Map<Object, Object> data = new HashMap<Object, Object>();
        data.put("infoList",infoList);
        return ResponseUtil.ok(data);
    }
}
package com.jwj.minoa.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Date;

@ApiModel(description = "会议信息")
public class Info {
    @ApiModelProperty(value = "会议ID", name="id", required = false)
    private Long id;

    @ApiModelProperty(value = "会议标题", name="title", required = false)
    private String title;

    @ApiModelProperty(value = "会议内容", name="content", required = false)
    private String content;

    @ApiModelProperty(value = "参与者", name="canyuze", required = false)
    private String canyuze;

    @ApiModelProperty(value = "列席人员", name="liexize", required = false)
    private String liexize;

    @ApiModelProperty(value = "主持人", name="zhuchiren", required = false)
    private String zhuchiren;

    @ApiModelProperty(value = "会议地点", name="location", required = false)
    private String location;

    @ApiModelProperty(value = "会议开始时间", name="starttime", required = false)
    private Date starttime;

    @ApiModelProperty(value = "会议结束时间", name="endtime", required = false)
    private Date endtime;

    @ApiModelProperty(value = "附件", name="fujian", required = false)
    private String fujian;

    @ApiModelProperty(value = "会议状态", name="state", required = false)
    private Integer state;

    @ApiModelProperty(value = "审批人", name="auditperson", required = false)
    private String auditperson;

    @ApiModelProperty(value = "审批时间", name="audittime", required = false)
    private Date audittime;

    @ApiModelProperty(value = "会议座位图片", name="seatpic", required = false)
    private String seatpic;

    @ApiModelProperty(value = "备注", name="remark", required = false)
    private String remark;

    public Info(Long id, String title, String content, String canyuze, String liexize, String zhuchiren, String location, Date starttime, Date endtime, String fujian, Integer state, String auditperson, Date audittime, String seatpic, String remark) {
        this.id = id;
        this.title = title;
        this.content = content;
        this.canyuze = canyuze;
        this.liexize = liexize;
        this.zhuchiren = zhuchiren;
        this.location = location;
        this.starttime = starttime;
        this.endtime = endtime;
        this.fujian = fujian;
        this.state = state;
        this.auditperson = auditperson;
        this.audittime = audittime;
        this.seatpic = seatpic;
        this.remark = remark;
    }

    public Info() {
        super();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getCanyuze() {
        return canyuze;
    }

    public void setCanyuze(String canyuze) {
        this.canyuze = canyuze;
    }

    public String getLiexize() {
        return liexize;
    }

    public void setLiexize(String liexize) {
        this.liexize = liexize;
    }

    public String getZhuchiren() {
        return zhuchiren;
    }

    public void setZhuchiren(String zhuchiren) {
        this.zhuchiren = zhuchiren;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public Date getStarttime() {
        return starttime;
    }

    public void setStarttime(Date starttime) {
        this.starttime = starttime;
    }

    public Date getEndtime() {
        return endtime;
    }

    public void setEndtime(Date endtime) {
        this.endtime = endtime;
    }

    public String getFujian() {
        return fujian;
    }

    public void setFujian(String fujian) {
        this.fujian = fujian;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String getAuditperson() {
        return auditperson;
    }

    public void setAuditperson(String auditperson) {
        this.auditperson = auditperson;
    }

    public Date getAudittime() {
        return audittime;
    }

    public void setAudittime(Date audittime) {
        this.audittime = audittime;
    }

    public String getSeatpic() {
        return seatpic;
    }

    public void setSeatpic(String seatpic) {
        this.seatpic = seatpic;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
}

5.测试效果如下图所示:

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/174517.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

2022年PTA行业研究报告

第一章 行业概况 PTA是精对苯二甲酸&#xff08;Pure Terephthalic Acid&#xff09;的英文简称&#xff0c;在常温下是白色粉状晶体, 无毒、易燃&#xff0c;若与空气混合&#xff0c;在一定限度内遇火即燃烧。 PTA是重要的大宗有机原料之一&#xff0c;广泛用于化学纤维、轻…

【数据结构入门】-线性表之顺序表(1)

个人主页&#xff1a;平行线也会相交 欢迎 点赞&#x1f44d; 收藏✨ 留言✉ 加关注&#x1f493;本文由 平行线也会相交 原创 收录于专栏【数据结构】 从今天开始&#xff0c;就正式进入数据结构的大门了&#xff0c;把握机会&#xff0c;好好学习&#xff0c;加油。 本文目录…

Arduino环境下对NodeMCU ESP8266将文件直接传入flash的三种方式

flash存储简答介绍 参考&#xff1a;https://www.elecfans.com/consume/572040.html flash存储器又称闪存&#xff08;快闪存储器&#xff09;&#xff0c;就其本质而言&#xff0c;flash存储器属于EEPROM&#xff08;电擦除可编程只读存储器&#xff09;类型。是一种长寿命的…

Java多线程案例之单例模式

目录 一、饿汉模式 二、懒汉模式 前言&#xff1a;单例模式是校招中最常见的设计模式之一。下面我们来谈谈其中的两个模式&#xff1a;懒汉&#xff0c;饿汉。 何为设计模式&#xff1f; 设计模式是软件开发人员在软件开发过程中面临的一般问题的解决方案。这些解决方案是众多…

【涂鸦蓝牙SDK】基于涂鸦蓝牙SDK数据传输与函数接口解析

基于涂鸦蓝牙SDK数据传输与函数接口解析1.【数据初始化部分】2.【蓝牙状态机控制】3.【数据广播过程】4.【涂鸦平台申请设备以及SDK】5.【涂鸦SDK模组源码思路解析】---- 重要&#xff1a;5.1 数据收发5.【移植涂鸦评估】2023.1.21 本文是基于涂鸦SDK的低功耗蓝牙BLE协议的数据…

Linux创建解压后的应用程序的桌面快捷方式

下面用一个例子演示&#xff0c;其他应用也差不多 下载好的安装文件为.tar.xz格式&#xff0c;通常默认在系统的下载文件夹下&#xff08;按你实际路径&#xff09;。右键点击文件&#xff0c;在下拉框中点击提取到此处&#xff08;意思就是解压&#xff09;。 解压后&#xff…

DocArray 0.21.0版本发布!新增OpenSearch后端存储,支持Redis后端存储的多语言文本搜索!...

github.com/docarray/docarrayDocArray 是一个用于处理、传输和存储多模态数据的 Python 工具包。DocArray 提供便捷的多模态数据处理功能&#xff0c;具备基于 Protobuf 提供高性能的网络传输性能&#xff0c;同时也为多种向量存储方案提供统一的 API 接口。&#x1f4a1; Doc…

三十三、Kubernetes中Service详解、实例第三篇

1、概述 在kubernetes中&#xff0c;pod是应用程序的载体&#xff0c;我们可以通过pod的ip来访问应用程序&#xff0c;但是pod的ip地址不是固定的&#xff0c;这也就意味着不方便直接采用pod的ip对服务进行访问。 为了解决这个问题&#xff0c;kubernetes提供了Service资源&…

06.动态内存管理

1. 存在动态内存分配的原因我们已经掌握的内存开辟方式有&#xff1a;int val 20;//在栈空间上开辟四个字节 char arr[10] { 0 };//在栈空间上开辟10个字节的连续空间//写死了 //变长数组&#xff0c;int arr[n]&#xff0c;变量的方式可以指定大小&#xff0c;并非意味着数组…

0th HPC Game小结

PART 1 - 基础知识 一、文件读取 二进制文件 mmap https://hpcgame.pku.edu.cn/demo/scow/api/proxy/relative/192.168.100.61/35515/ fread fwrite //readFILE* fi;if(fi fopen("input.bin", "rb")){fread(&p, sizeof(int), 1, fi);fread(&n,…

RabbitMQ之消息转换器

前言&#xff1a;大家好&#xff0c;我是小威&#xff0c;24届毕业生&#xff0c;曾经在某央企公司实习&#xff0c;目前在某税务公司。本篇文章将记录和分享RabbitMQ消息转换器的知识点。 本篇文章记录的基础知识&#xff0c;适合在学Java的小白&#xff0c;也适合复习中&…

深入理解机器学习——关联规则挖掘:基础知识

分类目录&#xff1a;《深入理解机器学习》总目录 许多商业企业在日复一日的运营中积聚了大量的数据。例如&#xff0c;食品商店的收银台每天都收集大量的顾客购物数据。下图给出一个这种数据的例子&#xff0c;通常称作购物篮事务&#xff08;Market Basket Transaction&#…

Elasticsearch基本使用初体验01

ElasticSearch是一款非常强大的、基于Lucene的开源搜索及分析引擎&#xff1b;它是一个实时的分布式搜索分析引擎&#xff0c;它能让你以前所未有的速度和规模&#xff0c;去探索你的数据。 1.es的安装 工欲善其事&#xff0c;必先利其器&#xff1b;想要学es&#xff0c;我们…

九龙证券|磷酸铁锂电池包和铅酸电池有哪些区别?

目前&#xff0c;新能源汽车电动车一般用的电池有3种&#xff0c;铅酸蓄电池、镍氢充电电池、锂离子电池。伴随着电动车蓄电池技能工艺的升级换代&#xff0c;锂电池的发展壮大和应用领域日益持续上升。那么&#xff0c;磷酸铁锂电池包和铅酸电池有哪些差异呢&#xff1f;铅酸蓄…

PowerShell 美化(oh-my-posh)

文章目录PowerShell 美化一、 添加右键菜单1、 修改默认右键菜单2、 寻找安装目录3、 修改注册表二、 样式修改1、 环境安装2、 配置使用PowerShell 美化 一、 添加右键菜单 1、 修改默认右键菜单 直接使用这个命令可以将 win11 的右键菜单修改为 win10 的右键菜单&#xff1…

基础数学(三)位运算 JZ 15.位1的个数

正在刷DFS相关题的时候突然间&#xff0c;给我蹦出来这样一个回溯题&#xff1a; 401. 二进制手表 二进制手表顶部有 4 个 LED 代表 小时&#xff08;0-11&#xff09;&#xff0c;底部的 6 个 LED 代表 分钟&#xff08;0-59&#xff09;。每个 LED 代表一个 0 或 1&#xff…

maven 解决Cannot access alimaven以及Process terminated

maven 解决Cannot access alimaven以及Process terminated 目录maven 解决Cannot access alimaven以及Process terminated方案一&#xff1a;用idea打开settings.xml&#xff0c;更正红色报错方案二&#xff1a;将IDEA的Maven默认版本更换成你下载的maven文件夹方案三&#xff…

单片机堆栈知识总结

堆栈 在片内RAM中&#xff0c;常常要指定一个专门的区域来存放某些特别的数据 它遵循顺序存取和后进先出(LIFO/FILO)的原则&#xff0c;这个RAM区叫堆栈。 其实堆栈就是单片机中的一些存储单元&#xff0c;这些存储单元被指定保存一些特殊信息&#xff0c;比如地址&#xff0…

DFS(二)岛屿问题合集

目录 一、 463. 岛屿的周长 二、 130. 被围绕的区域 三、 200. 岛屿数量 四、695. 岛屿的最大面积 一、463. 岛屿的周长 给定一个 row x col 的二维网格地图 grid &#xff0c;其中&#xff1a;grid[i][j] 1 表示陆地&#xff0c; grid[i][j] 0 表示水域。 网格中的格子 …

Java设计模式-解释器模式、解释器模式什么回事,抽象语法树又是什么

继续整理记录这段时间来的收获&#xff0c;详细代码可在我的Gitee仓库SpringBoot克隆下载学习使用&#xff01; 6.12 解释器模式 6.12.1 概述 思维&#xff1a;翻译识别机器&#xff0c;如解析由数字、“”、“-”号构成的合法运算序列&#xff0c;若将数字和字符看作结点&a…