【黑马头条之对象存储服务MinIO】

news2024/10/5 19:19:00

本笔记内容为黑马头条项目的对象存储服务MinIO部分

目录

一、MinIO简介

二、MinIO特点

三、开箱使用

1、安装启动

2、管理控制台

四、快速入门

1、创建工程,导入pom依赖

五、封装MinIO为starter

1、创建模块heima-file-starter

2、配置类

3、封装操作minIO类

4、对外加入自动配置

5、其他微服务使用

五、结合freemarker实现文章详情功能

1.需求分析

2、实现方案

3、实现步骤


一、MinIO简介


MinIO基于Apache License v2.0开源协议的对象存储服务,可以做为云存储的解决方案用来保存海量的图片,视频,文档。由于采用Golang实现,服务端可以工作在Windows,Linux, OS X和FreeBSD上。配置简单,基本是复制可执行程序,单行命令可以运行起来。

MinIO兼容亚马逊S3云存储服务接口,非常适合于存储大容量非结构化的数据,例如图片、视频、日志文件、备份数据和容器/虚拟机镜像等,而一个对象文件可以是任意大小,从几kb到最大5T不等。

S3 ( Simple Storage Service简单存储服务)

基本概念

  • bucket – 类比于文件系统的目录

  • Object – 类比文件系统的文件

  • Keys – 类比文件名

官网文档:MinIO Object Storage for Kubernetes — MinIO Object Storage for Kubernetes

二、MinIO特点


  • 数据保护

    Minio使用Minio Erasure Code(纠删码)来防止硬件故障。即便损坏一半以上的driver,但是仍然可以从中恢复。

  • 高性能

    作为高性能对象存储,在标准硬件条件下它能达到55GB/s的读、35GB/s的写速率

  • 可扩容

    不同MinIO集群可以组成联邦,并形成一个全局的命名空间,并跨越多个数据中心

  • SDK支持

    基于Minio轻量的特点,它得到类似Java、Python或Go等语言的sdk支持

  • 有操作页面

    面向用户友好的简单操作界面,非常方便的管理Bucket及里面的文件资源

  • 功能简单

    这一设计原则让MinIO不容易出错、更快启动

  • 丰富的API

    支持文件资源的分享连接及分享链接的过期策略、存储桶操作、文件列表访问及文件上传下载的基本功能等。

  • 文件变化主动通知

    存储桶(Bucket)如果发生改变,比如上传对象和删除对象,可以使用存储桶事件通知机制进行监控,并通过以下方式发布出去:AMQP、MQTT、Elasticsearch、Redis、NATS、MySQL、Kafka、Webhooks等。

三、开箱使用


1、安装启动

我们可以使用docker进行环境部署和启动

MINIO_ACCESS_KEY和MINIO_SECRET_KEY设置为自己要的,登录要用

docker run -p 9000:9000 --name minio -d --restart=always -e "MINIO_ACCESS_KEY=minio" -e "MINIO_SECRET_KEY=minio123" -v /home/data:/data -v /home/config:/root/.minio minio/minio server /data

2、管理控制台

假设我们的服务器地址为http://192.168.200.130:9000

我们在地址栏输入:http://http://192.168.200.130:9000/ 即可进入登录界面。

Access Key为minio Secret_key 为minio123 进入系统后可以看到主界面

点击右下角的“+”号 ,点击下面的图标,创建一个桶

四、快速入门


1、创建工程,导入pom依赖

创建minio-demo,对应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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>heima-leadnews-test</artifactId>
        <groupId>com.heima</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>minio-demo</artifactId>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <dependencies>

        <dependency>
            <groupId>io.minio</groupId>
            <artifactId>minio</artifactId>
            <version>7.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

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

</project>

引导类:

package com.heima.minio;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


@SpringBootApplication
public class MinIOApplication {

    public static void main(String[] args) {
        SpringApplication.run(MinIOApplication.class,args);
    }
}

创建测试类,上传html文件

package com.heima.minio.test;

import io.minio.MinioClient;
import io.minio.PutObjectArgs;

import java.io.FileInputStream;

public class MinIOTest {


    public static void main(String[] args) {

        FileInputStream fileInputStream = null;
        try {

            fileInputStream =  new FileInputStream("D:\\list.html");;

            //1.创建minio链接客户端
            MinioClient minioClient = MinioClient.builder().credentials("minio", "minio123").endpoint("http://192.168.200.130:9000").build();
            //2.上传
            PutObjectArgs putObjectArgs = PutObjectArgs.builder()
                    .object("list.html")//文件名
                    .contentType("text/html")//文件类型
                    .bucket("leadnews")//桶名词  与minio创建的名词一致
                    .stream(fileInputStream, fileInputStream.available(), -1) //文件流
                    .build();
            minioClient.putObject(putObjectArgs);

            System.out.println("http://192.168.200.130:9000/leadnews/ak47.jpg");

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

}

五、封装MinIO为starter


1、创建模块heima-file-starter

导入依赖        

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-autoconfigure</artifactId>
    </dependency>
    <dependency>
        <groupId>io.minio</groupId>
        <artifactId>minio</artifactId>
        <version>7.1.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
</dependencies>

2、配置类

MinIOConfigProperties

package com.heima.file.config;


import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.io.Serializable;

@Data
@ConfigurationProperties(prefix = "minio")  // 文件上传 配置前缀file.oss
public class MinIOConfigProperties implements Serializable {

    private String accessKey;
    private String secretKey;
    private String bucket;
    private String endpoint;
    private String readPath;
}

MinIOConfig

package com.heima.file.config;

import com.heima.file.service.FileStorageService;
import io.minio.MinioClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Data
@Configuration
@EnableConfigurationProperties({MinIOConfigProperties.class})
//当引入FileStorageService接口时
@ConditionalOnClass(FileStorageService.class)
public class MinIOConfig {

   @Autowired
   private MinIOConfigProperties minIOConfigProperties;

    @Bean
    public MinioClient buildMinioClient(){
        return MinioClient
                .builder()
                .credentials(minIOConfigProperties.getAccessKey(), minIOConfigProperties.getSecretKey())
                .endpoint(minIOConfigProperties.getEndpoint())
                .build();
    }
}

3、封装操作minIO类

FileStorageService

package com.heima.file.service;

import java.io.InputStream;

/**
 * @author itheima
 */
public interface FileStorageService {


    /**
     *  上传图片文件
     * @param prefix  文件前缀
     * @param filename  文件名
     * @param inputStream 文件流
     * @return  文件全路径
     */
    public String uploadImgFile(String prefix, String filename,InputStream inputStream);

    /**
     *  上传html文件
     * @param prefix  文件前缀
     * @param filename   文件名
     * @param inputStream  文件流
     * @return  文件全路径
     */
    public String uploadHtmlFile(String prefix, String filename,InputStream inputStream);

    /**
     * 删除文件
     * @param pathUrl  文件全路径
     */
    public void delete(String pathUrl);

    /**
     * 下载文件
     * @param pathUrl  文件全路径
     * @return
     *
     */
    public byte[]  downLoadFile(String pathUrl);

}

MinIOFileStorageService

package com.heima.file.service.impl;


import com.heima.file.config.MinIOConfig;
import com.heima.file.config.MinIOConfigProperties;
import com.heima.file.service.FileStorageService;
import io.minio.GetObjectArgs;
import io.minio.MinioClient;
import io.minio.PutObjectArgs;
import io.minio.RemoveObjectArgs;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Import;
import org.springframework.util.StringUtils;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;

@Slf4j
@EnableConfigurationProperties(MinIOConfigProperties.class)
@Import(MinIOConfig.class)
public class MinIOFileStorageService implements FileStorageService {

    @Autowired
    private MinioClient minioClient;

    @Autowired
    private MinIOConfigProperties minIOConfigProperties;

    private final static String separator = "/";

    /**
     * @param dirPath
     * @param filename  yyyy/mm/dd/file.jpg
     * @return
     */
    public String builderFilePath(String dirPath,String filename) {
        StringBuilder stringBuilder = new StringBuilder(50);
        if(!StringUtils.isEmpty(dirPath)){
            stringBuilder.append(dirPath).append(separator);
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
        String todayStr = sdf.format(new Date());
        stringBuilder.append(todayStr).append(separator);
        stringBuilder.append(filename);
        return stringBuilder.toString();
    }

    /**
     *  上传图片文件
     * @param prefix  文件前缀
     * @param filename  文件名
     * @param inputStream 文件流
     * @return  文件全路径
     */
    @Override
    public String uploadImgFile(String prefix, String filename,InputStream inputStream) {
        String filePath = builderFilePath(prefix, filename);
        try {
            PutObjectArgs putObjectArgs = PutObjectArgs.builder()
                    .object(filePath)
                    .contentType("image/jpg")
                    .bucket(minIOConfigProperties.getBucket()).stream(inputStream,inputStream.available(),-1)
                    .build();
            minioClient.putObject(putObjectArgs);
            StringBuilder urlPath = new StringBuilder(minIOConfigProperties.getReadPath());
            urlPath.append(separator+minIOConfigProperties.getBucket());
            urlPath.append(separator);
            urlPath.append(filePath);
            return urlPath.toString();
        }catch (Exception ex){
            log.error("minio put file error.",ex);
            throw new RuntimeException("上传文件失败");
        }
    }

    /**
     *  上传html文件
     * @param prefix  文件前缀
     * @param filename   文件名
     * @param inputStream  文件流
     * @return  文件全路径
     */
    @Override
    public String uploadHtmlFile(String prefix, String filename,InputStream inputStream) {
        String filePath = builderFilePath(prefix, filename);
        try {
            PutObjectArgs putObjectArgs = PutObjectArgs.builder()
                    .object(filePath)
                    .contentType("text/html")
                    .bucket(minIOConfigProperties.getBucket()).stream(inputStream,inputStream.available(),-1)
                    .build();
            minioClient.putObject(putObjectArgs);
            StringBuilder urlPath = new StringBuilder(minIOConfigProperties.getReadPath());
            urlPath.append(separator+minIOConfigProperties.getBucket());
            urlPath.append(separator);
            urlPath.append(filePath);
            return urlPath.toString();
        }catch (Exception ex){
            log.error("minio put file error.",ex);
            ex.printStackTrace();
            throw new RuntimeException("上传文件失败");
        }
    }

    /**
     * 删除文件
     * @param pathUrl  文件全路径
     */
    @Override
    public void delete(String pathUrl) {
        String key = pathUrl.replace(minIOConfigProperties.getEndpoint()+"/","");
        int index = key.indexOf(separator);
        String bucket = key.substring(0,index);
        String filePath = key.substring(index+1);
        // 删除Objects
        RemoveObjectArgs removeObjectArgs = RemoveObjectArgs.builder().bucket(bucket).object(filePath).build();
        try {
            minioClient.removeObject(removeObjectArgs);
        } catch (Exception e) {
            log.error("minio remove file error.  pathUrl:{}",pathUrl);
            e.printStackTrace();
        }
    }


    /**
     * 下载文件
     * @param pathUrl  文件全路径
     * @return  文件流
     *
     */
    @Override
    public byte[] downLoadFile(String pathUrl)  {
        String key = pathUrl.replace(minIOConfigProperties.getEndpoint()+"/","");
        int index = key.indexOf(separator);
        String bucket = key.substring(0,index);
        String filePath = key.substring(index+1);
        InputStream inputStream = null;
        try {
            inputStream = minioClient.getObject(GetObjectArgs.builder().bucket(minIOConfigProperties.getBucket()).object(filePath).build());
        } catch (Exception e) {
            log.error("minio down file error.  pathUrl:{}",pathUrl);
            e.printStackTrace();
        }

        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        byte[] buff = new byte[100];
        int rc = 0;
        while (true) {
            try {
                if (!((rc = inputStream.read(buff, 0, 100)) > 0)) break;
            } catch (IOException e) {
                e.printStackTrace();
            }
            byteArrayOutputStream.write(buff, 0, rc);
        }
        return byteArrayOutputStream.toByteArray();
    }
}

4、对外加入自动配置

在resources中新建META-INF/spring.factories         

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
  com.heima.file.service.impl.MinIOFileStorageService

5、其他微服务使用

第一,导入heima-file-starter的依赖

第二,在微服务中添加minio所需要的配置

minio:
  accessKey: minio
  secretKey: minio123
  bucket: leadnews
  endpoint: http://192.168.200.130:9000
  readPath: http://192.168.200.130:9000

第三,在对应使用的业务类中注入FileStorageService,样例如下:

package com.heima.minio.test;


import com.heima.file.service.FileStorageService;
import com.heima.minio.MinioApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

@SpringBootTest(classes = MinioApplication.class)
@RunWith(SpringRunner.class)
public class MinioTest {

    @Autowired
    private FileStorageService fileStorageService;

    @Test
    public void testUpdateImgFile() {
        try {
            FileInputStream fileInputStream = new FileInputStream("E:\\tmp\\ak47.jpg");
            String filePath = fileStorageService.uploadImgFile("", "ak47.jpg", fileInputStream);
            System.out.println(filePath);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}

五、结合freemarker实现文章详情功能


1.需求分析

2、实现方案

方案一

用户某一条文章,根据文章的id去查询文章内容表,返回渲染页面

方案二

3、实现步骤

1.在artile微服务中添加MinIO和freemarker的支持,参考测试项目

2.资料中找到模板文件(article.ftl)拷贝到article微服务下

3.资料中找到index.js和index.css两个文件手动上传到MinIO中

4.在文章微服务中导入依赖

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-freemarker</artifactId>
    </dependency>
    <dependency>
        <groupId>com.heima</groupId>
        <artifactId>heima-file-starter</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
</dependencies>

5.新建ApArticleContentMapper

package com.heima.article.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.heima.model.article.pojos.ApArticleContent;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface ApArticleContentMapper extends BaseMapper<ApArticleContent> {
}

6.在artile微服务中新增测试类(后期新增文章的时候创建详情静态页,目前暂时手动生成

package com.heima.article.test;


import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.article.ArticleApplication;
import com.heima.article.mapper.ApArticleContentMapper;
import com.heima.article.mapper.ApArticleMapper;
import com.heima.file.service.FileStorageService;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.article.pojos.ApArticleContent;
import freemarker.template.Configuration;
import freemarker.template.Template;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;

@SpringBootTest(classes = ArticleApplication.class)
@RunWith(SpringRunner.class)
public class ArticleFreemarkerTest {

    @Autowired
    private Configuration configuration;

    @Autowired
    private FileStorageService fileStorageService;


    @Autowired
    private ApArticleMapper apArticleMapper;

    @Autowired
    private ApArticleContentMapper apArticleContentMapper;

    @Test
    public void createStaticUrlTest() throws Exception {
        //1.获取文章内容
        ApArticleContent apArticleContent = apArticleContentMapper.selectOne(Wrappers.<ApArticleContent>lambdaQuery().eq(ApArticleContent::getArticleId, 1390536764510310401L));
        if(apArticleContent != null && StringUtils.isNotBlank(apArticleContent.getContent())){
            //2.文章内容通过freemarker生成html文件
            StringWriter out = new StringWriter();
            Template template = configuration.getTemplate("article.ftl");

            Map<String, Object> params = new HashMap<>();
            params.put("content", JSONArray.parseArray(apArticleContent.getContent()));

            template.process(params, out);
            InputStream is = new ByteArrayInputStream(out.toString().getBytes());

            //3.把html文件上传到minio中
            String path = fileStorageService.uploadHtmlFile("", apArticleContent.getArticleId() + ".html", is);

            //4.修改ap_article表,保存static_url字段
            ApArticle article = new ApArticle();
            article.setId(apArticleContent.getArticleId());
            article.setStaticUrl(path);
            apArticleMapper.updateById(article);

        }
    }
}

然后启动网关等服务点击刚上传对应的文章就可以看到详情内容了

结束!

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

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

相关文章

VBA命令及语法列表之字典Dictionaries相关

【分享成果&#xff0c;随喜正能量】真正的修佛之人。首先&#xff0c;得明白自己的来处和归宿&#xff0c;懂得敬畏自己的生命和他人的生命&#xff0c;尽其所能释放善意。学会悲天悯人&#xff0c;渡人的同时渡己&#xff0c;始终走在止于至善的路上。真正的慈悲为怀&#xf…

有哪些方法可将PPT转成PDF?分享三个方法给大家!

将PPT&#xff08;演示文稿&#xff09;文件转换为PDF&#xff08;便携式文档格式&#xff09;是一种常见的需求&#xff0c;特别适用于共享演示文稿、打印或以静态格式保存的情况。本文将介绍三种简单易用的方法来实现PPT转PDF的操作&#xff0c;其中方法一是使用记灵在线工具…

MarkDown 生成目录的树结构

1. tree 命令的使用 Markdown没有办法直接生成目录的树结构&#xff0c;需要借助Windows下的tree命令&#xff0c;具体如下&#xff1a; 显示所有目录&#xff0c;不包含目录下的文件&#xff0c;tree 文件夹路径 显示所有目录&#xff0c;包含目录下的文件&#xff0c;tree …

命令行查看numpy版本

问题 查看numpy版本 解决方法 python -c "import numpy;print(numpy.version.version)"成功

OpenCV中reshape()函数详解-改变矩阵的通道数,对矩阵元素进行序列化

文章目录 1、函数原型2、示例3、结论&#xff1a; OpenCV中reshape()函数详解-改变矩阵的通道数&#xff0c;对矩阵元素进行序列化 在opencv中reshape函数&#xff0c;既可以改变矩阵的通道数&#xff0c;又可以对矩阵元素进行序列化 1、函数原型 Mat Mat::reshape(int cn, in…

echarts_雷达图

目录 雷达图(radar)需求[1] 复制案例[2] 色调统一[3] 配置项实现代码 雷达图(radar) 需求 [1] 复制案例 如上图&#xff0c;先复制一个最简单的雷达图 [2] 色调统一 直角系坐标都是使用xAxis/yAxis配置项&#xff0c;但是雷达图使用的是radar配置项配置坐标系。 配置项注解区…

GoFrame v2.5 版本发布,企业级 Golang 开发框架

大家好啊&#xff0c;GoFrame 框架今天发布了 v2.5.0 正式版本啦&#xff01;&#x1f44f;&#x1f44f;&#x1f44f;&#x1f44f; 本次版本主要是对已有功能组件以及开发工具上的改进工作。其中&#xff0c;开发工具新增了 gf gen ctrl 命令&#xff0c;以规范化定义、开发…

【C#】并行编程实战:使用并发集合

在上一章的并行编程实现里&#xff0c;为了保护资源&#xff0c;我们对共享资源加锁&#xff08;各种同步原语&#xff09;来进行保护&#xff0c;避免多线程同时访问&#xff08;主要是写入&#xff09;。但一般来说&#xff0c;共享资源是一个可以由多个线程读写的集合&#…

AR气象博物馆模拟体验提升青少年认知

国际气象节主要目的是唤起人们对气象工作的重视和热爱。近年来&#xff0c;极端天气频发&#xff0c;人们需要提高警惕&#xff0c;AR气象远程普利用ar技术特有的沉浸式的体感互动&#xff0c;通过模拟演练提升体验者的安全防范意识和求生技巧。 系统结合VR虚拟现实、AR增强现实…

【多模态】1、几种多模态 vision-language 任务和数据集介绍

文章目录 一、Phrase Grounding1.1 概念介绍1.2 常用数据集介绍 二、Referring Expression Comprehension&#xff08;REC&#xff09;2.1 概念介绍2.2 常用数据集介绍 三、Visual Question Answer&#xff08;VQA&#xff09;3.1 概念介绍 四、Image Caption4.1 概念介绍 现在…

MySQL-数据库读写分离(上)

♥️作者&#xff1a;小刘在C站 ♥️个人主页&#xff1a; 小刘主页 ♥️努力不一定有回报&#xff0c;但一定会有收获加油&#xff01;一起努力&#xff0c;共赴美好人生&#xff01; ♥️学习两年总结出的运维经验&#xff0c;以及思科模拟器全套网络实验教程。专栏&#xf…

(学习笔记-TCP连接建立)为什么每次建立TCP连接时,初始化的序列号都要求不一样?

主要原因有两个方面&#xff1a; 为了防止历史报文被下一个相同的四元组的连接接收(主要)为了安全性&#xff0c;防止黑客伪造相同序列号的TCP报文被对方接收 展开第一点&#xff1a; 假设每次建立连接&#xff0c;客户端恶核服务端的初始化序列号都是从0开始&#xff1a; 过程…

Mysql教程(一):Mysql数据模型和SQL语法分析

Mysql教程&#xff08;一&#xff09;&#xff1a;Mysql数据模型和SQL语法分析 1、Mysql数据模型 1.1 关系型数据库&#xff08;RDBMS&#xff09; 概念&#xff1a;建立在关系模型基础上&#xff0c;由多张相互连接的二维表组成的数据库。 特点&#xff1a; 使用表存储数…

H5活动营销系统怎么做?H5活动营销系统有哪些优势?

H5营销系统广泛用于各类线下活动场景&#xff0c;即将传统线下活动搬到线上&#xff0c;结合互动和奖励设计&#xff0c;引导用户产生转发、分享等目标行为&#xff0c;从而扩大活动影响力&#xff0c;以获得曝光和转化。因此&#xff0c;h5活动营销系统通常用于拉新促活、刺激…

【LeetCode 75】第三题(1431)拥有最多糖果的孩子

题目: 示例: 分析: 题目是简单题,也确实简单,不过示例给出的解释有些复杂,甚至有些误导.我们只需要遍历得出分配糖果之前的糖果最大值,然后再依次遍历每个孩子拥有的糖果数,若某孩子原有的糖果数加上待分配的所有糖果数大于等于分配前的糖果最大值,则给该孩子对应下标的结果置…

Linux--进程替换(转载)

目录 0.引入 1.替换原理 2.替换函数 execl execv execlp execle execvp execvpe execve 3.调用自定义程序 4.exec函数解释 5.命名理解 0.引入 创建子进程的目的是什么&#xff1f; 就是为了让子进程帮我执行特定的任务 让子进程执行父进程的一部分代码 如果子进程…

深度学习——自编码器AutoEncoder

基本概念 概述 自编码器&#xff08;Autoencoder&#xff09;是一种无监督学习的神经网络模型&#xff0c;用于学习数据的低维表示。它由编码器&#xff08;Encoder&#xff09;和解码器&#xff08;Decoder&#xff09;两部分组成&#xff0c;通过将输入数据压缩到低维编码空…

小程序使用云函数调用第三方api避免域名备案

小程序使用云函数调用第三方api避免域名备案 在小程序开发中&#xff0c;如果需要调用第三方 API&#xff0c;但由于域名备案的限制无法直接在小程序中使用&#xff0c;我们可以利用云函数来解决这个问题。 1. 开通云开发 使用微信开发者工具打开小程序项目&#xff0c;点击…

IDEA 提交git 之后撤回操作

方式一 1.选择提交记录&#xff1b; 2、 右键git然后选择drop commit&#xff1b; 弊端&#xff1a;会将修改的代码全部进行删除操作 打开 IDEA 的 本地历史记录功能&#xff0c;对修改的内容进行复原 方式二&#xff1a; 1、撤回commit 2、选择项目——>右击git——…

ROS-Qt-转CMake编译以及qmake第三方库添加及其他

Qt 开发ROS 界面的方法 方法2 带ui的工作空间配置&#xff08;以ROS节点执行&#xff09; 步骤1 $ mkdir catkin_qt $ cd catkin_qt $ mkdir src $ cd src $ catkin_init_workpasce $ cd .. $ catkin_make $ cd src $ catkin_create_qt_pkg ros_ui roscpp rospy std_msgs $ …