使用minio搭建oss

文章目录

    • 1.minio安装
        • 1.拉取镜像
        • 2.启动容器
        • 3.开启端口
          • 1.9090端口
          • 2.9000端口
        • 4.访问
          • 1.网址http://:9090/
        • 5.创建一个桶
    • 2.minio文件服务基本环境搭建
        • 1.创建一个文件模块
        • 2.目录结构
        • 3.配置依赖
        • 3.application.yml 配置
        • 4.编写配置类MinioConfig.java,构建minioClient
        • 5.FileInfo.java 封装文件信息
        • 6.MinioUtil.java 文件工具类
        • 7.FileController.java 测试
        • 8.启动类 OssApplication.java
        • 9.启动测试
    • 3.传统模式
        • 1.目录结构和类图
        • 2.首先引入Lombok的依赖,使用@SneakyThrows注解抛出异常
        • 3.StorageService.java 存储的接口
        • 4.MinioStorageServiceImpl.java minio实现的接口
        • 5.如果有其他的服务比如阿里云也可以实现接口
        • 6.FileController.java 按照id来依赖注入进行调用
        • 7.测试
        • 8.缺点分析
    • 4.使用适配器模式优化
        • 1.类图
        • 2.新增一个阿里云的实现类 AliyunStorageServiceImpl.java
        • 3.抽取一个 FileService.java 构造器聚合接口
        • 4.StorageConfig.java 配置文件根据application.yml来给构造器注入不同的对象
        • 5.application.yml 指定要使用的oss
        • 6.FileController.java 组合一个FileService调用里面的方法
        • 7.测试

1.minio安装

1.拉取镜像
docker pull minio/minio

image-20240531085604926

2.启动容器
docker run -p 9000:9000 -p 9090:9090 \
 --name minio \
 -d --restart=always \
 -e "MINIO_ACCESS_KEY=" \
 -e "MINIO_SECRET_KEY=" \
 -v /mydata/minio/data:/data \
 minio/minio server \
 /data --console-address ":9090" -address ":9000"
3.开启端口
1.9090端口
systemctl start firewalld && firewall-cmd --permanent --add-port=9090/tcp && firewall-cmd --reload && firewall-cmd --query-port=9090/tcp

image-20240531090338979

2.9000端口
systemctl start firewalld && firewall-cmd --permanent --add-port=9000/tcp && firewall-cmd --reload && firewall-cmd --query-port=9000/tcp

image-20240531095156302

4.访问
1.网址http://:9090/
5.创建一个桶

image-20240531090828470

2.minio文件服务基本环境搭建

1.创建一个文件模块

image-20240531091221636

2.目录结构

image-20240531095613468

3.配置依赖
<!-- maven的配置 -->
<!-- 解决java: -source 1.5 中不支持 diamond 运算符 问题 -->
<properties>
    <java.version>1.8</java.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>2.4.2</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>2.4.2</version>
        <exclusions>
            <exclusion>
                <artifactId>spring-boot-starter-logging</artifactId>
                <groupId>org.springframework.boot</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- minio依赖 -->
    <dependency>
        <groupId>io.minio</groupId>
        <artifactId>minio</artifactId>
        <version>8.2.0</version>
    </dependency>
</dependencies>

<!-- 配置阿里云仓库 -->
<repositories>
    <repository>
        <id>central</id>
        <name>aliyun maven</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        <layout>default</layout>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

<!-- maven打包常规配置 -->
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
3.application.yml 配置
server:
  port: 4000
minio:
  url: http://:9000
  accessKey: 
  secretKey: 
4.编写配置类MinioConfig.java,构建minioClient
package com.sunxiansheng.oss.config;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Description: minio配置管理
 * @Author sun
 * @Create 2024/5/31 9:22
 * @Version 1.0
 */
@Configuration
public class MinioConfig {

    // minioUrl
    @Value("${minio.url}")
    private String url;

    // minio用户名
    @Value("${minio.accessKey}")
    private String accessKey;

    // minio密码
    @Value("${minio.secretKey}")
    private String secretKey;


    /**
     * 构造minioClient
     */
    @Bean
    public MinioClient getMinioClient() {
        return MinioClient.builder().endpoint(url).credentials(accessKey, secretKey).build();
    }

}
5.FileInfo.java 封装文件信息
package com.sunxiansheng.oss.entity;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 9:47
 * @Version 1.0
 */
public class FileInfo {

    private String fileName;

    private Boolean directoryFlag;

    private String etag;

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public Boolean getDirectoryFlag() {
        return directoryFlag;
    }

    public void setDirectoryFlag(Boolean directoryFlag) {
        this.directoryFlag = directoryFlag;
    }

    public String getEtag() {
        return etag;
    }

    public void setEtag(String etag) {
        this.etag = etag;
    }
}
6.MinioUtil.java 文件工具类
package com.sunxiansheng.oss.util;

import com.sunxiansheng.oss.entity.FileInfo;
import io.minio.*;
import io.minio.messages.Bucket;
import io.minio.messages.Item;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Description: minio文件操作工具
 * @Author sun
 * @Create 2024/5/31 9:30
 * @Version 1.0
 */
@Component
public class MinioUtil {

    @Resource
    private MinioClient minioClient;

    /**
     * 创建bucket桶
     */
    public void createBucket(String bucket) throws Exception {
        boolean exists = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucket).build());
        if (!exists) {
            minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucket).build());
        }
    }

    /**
     * 上传文件
     */
    public void uploadFile(InputStream inputStream, String bucket, String objectName) throws Exception {
        minioClient.putObject(PutObjectArgs.builder().bucket(bucket).object(objectName)
                .stream(inputStream, -1, Integer.MAX_VALUE).build());
    }

    /**
     * 列出所有桶
     */
    public List<String> getAllBucket() throws Exception {
        List<Bucket> buckets = minioClient.listBuckets();
        return buckets.stream().map(Bucket::name).collect(Collectors.toList());
    }

    /**
     * 列出当前桶及文件
     */
    public List<FileInfo> getAllFile(String bucket) throws Exception {
        Iterable<Result<Item>> results = minioClient.listObjects(
                ListObjectsArgs.builder().bucket(bucket).build());
        List<FileInfo> fileInfoList = new LinkedList<>();
        for (Result<Item> result : results) {
            FileInfo fileInfo = new FileInfo();
            Item item = result.get();
            fileInfo.setFileName(item.objectName());
            fileInfo.setDirectoryFlag(item.isDir());
            fileInfo.setEtag(item.etag());
            fileInfoList.add(fileInfo);
        }
        return fileInfoList;
    }

    /**
     * 下载文件
     */
    public InputStream downLoad(String bucket, String objectName) throws Exception {
        return minioClient.getObject(
                GetObjectArgs.builder().bucket(bucket).object(objectName).build()
        );
    }

    /**
     * 删除桶
     */
    public void deleteBucket(String bucket) throws Exception {
        minioClient.removeBucket(
                RemoveBucketArgs.builder().bucket(bucket).build()
        );
    }

    /**
     * 删除文件
     */
    public void deleteObject(String bucket, String objectName) throws Exception {
        minioClient.removeObject(
                RemoveObjectArgs.builder().bucket(bucket).object(objectName).build()
        );
    }

}
7.FileController.java 测试
package com.sunxiansheng.oss.controller;

import com.sunxiansheng.oss.util.MinioUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 9:53
 * @Version 1.0
 */
@RestController
public class FileController {

    @Resource
    private MinioUtil minioUtil;

    @RequestMapping("/testGetAllBuckets")
    public String testGetAllBuckets() throws Exception {
        List<String> allBucket = minioUtil.getAllBucket();
        return allBucket.get(0);
    }

}
8.启动类 OssApplication.java
package com.sunxiansheng.oss;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 9:20
 * @Version 1.0
 */
@SpringBootApplication
@ComponentScan("com.sunxiansheng")
public class OssApplication {
    
    public static void main(String[] args) {
        SpringApplication.run(OssApplication.class, args);
    }
}
9.启动测试

image-20240531095956479

image-20240531100012712

3.传统模式

1.目录结构和类图

image-20240531102824619

image-20240531112643283

2.首先引入Lombok的依赖,使用@SneakyThrows注解抛出异常
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.16</version>
        </dependency>
3.StorageService.java 存储的接口
package com.sunxiansheng.oss.service;

import com.sunxiansheng.oss.entity.FileInfo;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.List;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 10:03
 * @Version 1.0
 */
public interface StorageService {

    /**
     * 创建bucket桶
     */
    void createBucket(String bucket);

    /**
     * 上传文件
     */
    void uploadFile(MultipartFile uploadFile, String bucket, String objectName);

    /**
     * 列出所有桶
     */
    List<String> getAllBucket();

    /**
     * 列出当前桶及文件
     */
    List<FileInfo> getAllFile(String bucket);

    /**
     * 下载文件
     */
    InputStream downLoad(String bucket, String objectName);

    /**
     * 删除桶
     */
    void deleteBucket(String bucket);

    /**
     * 删除文件
     */
    void deleteObject(String bucket, String objectName);


}
4.MinioStorageServiceImpl.java minio实现的接口
package com.sunxiansheng.oss.service.impl;

import com.sunxiansheng.oss.entity.FileInfo;
import com.sunxiansheng.oss.service.StorageService;
import com.sunxiansheng.oss.util.MinioUtil;
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.InputStream;
import java.util.List;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 10:06
 * @Version 1.0
 */
@Service("minioStorageServiceImpl")
public class MinioStorageServiceImpl implements StorageService {
    @Resource
    private MinioUtil minioUtil;

    @Override
    @SneakyThrows // Lombok 自动抛出异常
    public void createBucket(String bucket) {
        minioUtil.createBucket(bucket);
    }

    @Override
    @SneakyThrows // Lombok 自动抛出异常
    public void uploadFile(MultipartFile uploadFile, String bucket, String objectName) {
        createBucket(bucket);
        if (objectName != null) {
            minioUtil.uploadFile(uploadFile.getInputStream(), bucket, objectName + "/" + uploadFile.getName());
        } else {
            minioUtil.uploadFile(uploadFile.getInputStream(), bucket, uploadFile.getName());
        }
    }

    @Override
    @SneakyThrows // Lombok 自动抛出异常
    public List<String> getAllBucket() {
        return minioUtil.getAllBucket();
    }

    @Override
    @SneakyThrows // Lombok 自动抛出异常
    public List<FileInfo> getAllFile(String bucket) {
        return minioUtil.getAllFile(bucket);
    }

    @Override
    @SneakyThrows // Lombok 自动抛出异常
    public InputStream downLoad(String bucket, String objectName) {
        return minioUtil.downLoad(bucket, objectName);
    }

    @Override
    @SneakyThrows // Lombok 自动抛出异常
    public void deleteBucket(String bucket) {
        minioUtil.deleteBucket(bucket);
    }

    @Override
    @SneakyThrows // Lombok 自动抛出异常
    public void deleteObject(String bucket, String objectName) {
        minioUtil.deleteObject(bucket, objectName);
    }
}
5.如果有其他的服务比如阿里云也可以实现接口
6.FileController.java 按照id来依赖注入进行调用
package com.sunxiansheng.oss.controller;

import com.sunxiansheng.oss.service.StorageService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 9:53
 * @Version 1.0
 */
@RestController
public class FileController {

    // 这里根据id进行依赖注入,如果还有阿里云的,就注入阿里云的即可
    @Resource
    private StorageService minioStorageServiceImpl;

    @RequestMapping("/listBuckets")
    public String testGetAllBuckets() throws Exception {
        List<String> allBucket = minioStorageServiceImpl.getAllBucket();
        return allBucket.get(0);
    }

}
7.测试

image-20240531103457742

8.缺点分析

如果需要修改为阿里云的,则需要修改注入的id,也就是所有的controller都需要修改

4.使用适配器模式优化

1.类图

image-20240531143453159

2.新增一个阿里云的实现类 AliyunStorageServiceImpl.java
package com.sunxiansheng.oss.service.impl;

import com.sunxiansheng.oss.entity.FileInfo;
import com.sunxiansheng.oss.service.StorageService;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 11:13
 * @Version 1.0
 */
@Service("aliyunStorageServiceImpl")
public class AliyunStorageServiceImpl implements StorageService {
    @Override
    public void createBucket(String bucket) {

    }

    @Override
    public void uploadFile(MultipartFile uploadFile, String bucket, String objectName) {

    }

    @Override
    public List<String> getAllBucket() {
        List<String> res = new ArrayList<>();
        res.add("aliyunBucket");
        return res;
    }

    @Override
    public List<FileInfo> getAllFile(String bucket) {
        return Collections.emptyList();
    }

    @Override
    public InputStream downLoad(String bucket, String objectName) {
        return null;
    }

    @Override
    public void deleteBucket(String bucket) {

    }

    @Override
    public void deleteObject(String bucket, String objectName) {

    }
}

3.抽取一个 FileService.java 构造器聚合接口
package com.sunxiansheng.oss.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 10:48
 * @Version 1.0
 */
@Service
public class FileService {

    private final StorageService storageService;

    @Autowired // 构造器注入,如果只有一个构造器,其实可以不加,会自动识别
    public FileService(StorageService storageService) {
        this.storageService = storageService;
    }

    /**
     * 列出所有桶
     */
    public List<String> getAllBucket() {
        return storageService.getAllBucket();
    }

}

4.StorageConfig.java 配置文件根据application.yml来给构造器注入不同的对象
package com.sunxiansheng.oss.config;

import com.sunxiansheng.oss.service.StorageService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 11:10
 * @Version 1.0
 */
@Configuration
public class StorageConfig {

    @Value("${storage.service.type}")
    private String storageType;

    @Resource
    private StorageService aliyunStorageServiceImpl;

    @Resource
    private StorageService minioStorageServiceImpl;

    @Bean
    public StorageService storageService() {
        if ("minio".equals(storageType)) {
            return minioStorageServiceImpl;
        } else if ("aliyun".equals(storageType)) {
            return aliyunStorageServiceImpl;
        } else {
            throw new IllegalArgumentException("未找到对应的文件存储处理");
        }
    }


}
5.application.yml 指定要使用的oss
6.FileController.java 组合一个FileService调用里面的方法
package com.sunxiansheng.oss.controller;

import com.sunxiansheng.oss.service.FileService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Description:
 * @Author sun
 * @Create 2024/5/31 9:53
 * @Version 1.0
 */
@RestController
public class FileController {

    // 这里根据id进行依赖注入,如果还有阿里云的,就注入阿里云的即可
    @Resource
    private FileService fileService;

    @RequestMapping("/listBuckets")
    public String testGetAllBuckets() throws Exception {
        List<String> allBucket = fileService.getAllBucket();
        return allBucket.get(0);
    }

}
7.测试

image-20240531143928470

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

用Python将PowerPoint演示文稿转换到图片和SVG

PowerPoint演示文稿作为展示创意、分享知识和表达观点的重要工具&#xff0c;被广泛应用于教育、商务汇报及个人项目展示等领域。然而&#xff0c;面对不同的分享场景与接收者需求&#xff0c;有时需要我们将PPT内容以图片形式保存与传播。这样能够避免软件兼容性的限制&#x…

【网络架构】keepalive

目录 一、keepalive基础 1.1 作用 1.2 原理 1.3 功能 二、keepalive安装 2.1 yum安装 2.2 编译安装 三、配置文件 3.1 keepalived相关文件 3.2 主配置的组成 3.2.1 全局配置 3.2.2 配置虚拟路由器 四、实际操作 4.1 lvskeepalived高可用群集 4.2 keepalivedngi…

iOS政策解读之三丨商务、设计和法律 “三重奏“

上一篇的iOS政策解读文章&#xff0c;我们从安全和性能两方面进行了学习和解读&#xff0c;这两个方面是最为重要&#xff0c;也是优先级最高的方面。 如果您还没来得及阅读&#xff0c;欢迎移步我们前两篇的解读文章&#xff1a; iOS政策解读之一丨App提交审核前注意事项必知…

建投数据人力资源管理系统APP完成迭代升级

近日&#xff0c;建投数据人力资源管理系统APP完成迭代升级。 此次升级思路&#xff0c;遵循提升移动应用的功能和用户体验&#xff1b;直观的界面、快速的响应速度和安全的数据存储&#xff1b;个性化的功能&#xff0c;以满足不同员工的需求和使用偏好。 人力资源管理系统A…

ozon定价计算器下载,ozon定价计算器

各位电商卖家们&#xff0c;大家好&#xff01;在这个竞争激烈的电商时代&#xff0c;你是否还在为产品定价而头疼不已&#xff1f;特别是在俄罗斯ozon电商平台&#xff0c;本土与跨境的定价策略更是需要精细把控。今天&#xff0c;就为大家带来一款强大的定价工具——萌啦ozon…

QT QThread 线程类的使用及示例

QThread 是 Qt 框架提供的一个用于处理多线程的类&#xff0c;它允许开发者编写具有并发功能的应用程序&#xff0c;提高程序的响应速度、执行效率和用户体验。 在操作系统中&#xff0c;线程是进程内的执行单元&#xff0c;拥有独立的执行路径。每个线程有自己独立的栈空间&a…

数据库同步最简单的方法

数据库同步到底有咩有简单的方法&#xff0c;有肯定是有的&#xff0c;就看你有咩有缘&#xff0c;看到这篇文章&#xff0c;你就是有缘人。众所周知&#xff0c;数据库同步向来都不是一件简单的事情&#xff0c;它很繁琐&#xff0c;很费精力&#xff0c;很考验经验&#xff0…

unity 导入的模型设置讲解

咱们先讲Model这一栏 Model Scene&#xff1a;场景级属性&#xff0c;例如是否导入灯光和照相机&#xff0c;以及使用什么比例因子。 Scale Factor&#xff1a;缩放因子&#xff08;也就是模型导入后大小如果小了或者大了在这里直接改是相当于该模型的大小的&#xff0c;而且在…

Windows系统开启python虚拟环境

.\env4socre\Scripts\activate : 无法加载文件 E:\SocreMan\env4socre\Scripts\Activate.ps1&#xff0c;因为在此系统上禁止运行脚本。 环境&#xff1a;windows 11、vscode 1、用管理员权限打开powershell 输入set-executionpolicy remotesigned&#xff0c;选择Y 2、返回v…

网工内推 | 网络工程师,IE认证优先,最高18k*14薪,周末双休

01 上海吾索信息科技有限公司 &#x1f537;招聘岗位&#xff1a;网络工程师 &#x1f537;岗位职责&#xff1a; 1&#xff09;具备网络系统运维服务经验以及数据库实施经验&#xff0c;具备网络系统认证相关资质或证书&#xff1b; 2&#xff09;掌握常用各设备的运维巡检…

Logback-打印方法名及代码行号

背景 公司产品使用了logback作为日志输出框架&#xff0c;日志输出的pattern里配置了打印调用方法名及代码行号的配置&#xff0c;但是实际输出的日志方法名总是显示? 在强迫症的驱使下&#xff0c;开启了探秘之旅 Logback版本 1.2.3 项目中Logging.pattern配置如下&#xff1…

【课程总结】Day12:YOLO的深入了解

前言 在【课程总结】Day11&#xff08;下&#xff09;&#xff1a;YOLO的入门使用一节中&#xff0c;我们已经了解YOLO的使用方法&#xff0c;使用过程非常简单&#xff0c;训练时只需要三行代码&#xff1a;引入YOLO&#xff0c;构建模型&#xff0c;训练模型&#xff1b;预测…

DevOps CMDB平台整合Jira工单

背景 在DevOps CMDB平台建设的过程中&#xff0c;我们可以很容易的将业务应用所涉及的云资源&#xff08;WAF、K8S、虚拟机等&#xff09;、CICD工具链&#xff08;Jenkins、ArgoCD&#xff09;、监控、日志等一次性的维护到CMDB平台&#xff0c;但随着时间的推移&#xff0c;…

《昇思25天学习打卡营第5天|onereal》

ShuffleNet网络介绍 ShuffleNetV1是旷视科技提出的一种计算高效的CNN模型&#xff0c;和MobileNet, SqueezeNet等一样主要应用在移动端&#xff0c;所以模型的设计目标就是利用有限的计算资源来达到最好的模型精度。ShuffleNetV1的设计核心是引入了两种操作&#xff1a;Pointw…

【51单片机入门】点亮数码管

文章目录 前言仿真图如何去绘制一个数字示例代码选择某个数码管显示某个数字 示例代码总结 前言 在嵌入式系统的世界中&#xff0c;单片机扮演着至关重要的角色。51单片机&#xff0c;作为最早的微控制器之一&#xff0c;至今仍被广泛应用在各种设备中。本文将介绍如何使用51单…

嵌入式Linux的浮点运算能力测试

嵌入式Linux的浮点运算能力测试 今天需要对一款ARM CPU的浮点数运算能力进行测试&#xff0c;采用了台式机上常用的SuperPI相同的原理&#xff1a;计算一定小数位数的圆周率来测试硬件的浮点数计算能力和稳定性。 首先下载计算软件的源代码&#xff0c;可以使用下面命令&#…

python使用动态属性访问JSON类数据,Get it!

目录 1、基础访问:内置json模块 📦 1.1 json.loads转换字符串 1.2 动态属性访问技巧 2、面向对象方式处理JSON 🛰️ 2.1 创建JSON数据模型类 2.2 动态属性与方法绑定 3、类型安全: 数据类(dataclasses)应用 🔒 3.1 数据类基础 3.2 自动从JSON解构数据 3.3 动态…

LLM大模型实战 —— DB-GPT阿里云部署指南

简介&#xff1a; DB-GPT 是一个实验性的开源应用&#xff0c;它基于FastChat&#xff0c;并使用vicuna-13b作为基础模型, 模型与数据全部本地化部署, 绝对保障数据的隐私安全。 同时此GPT项目可以直接本地部署连接到私有数据库, 进行私有数据处理&#xff0c; 目前已支持SQL生…

与国际接轨,与行业同行!2024深圳国际自有品牌展今日开幕!

2024深圳国际自有品牌展&#xff08;Marca China International Private Label Fair&#xff0c;简称“Marca China”&#xff09;于6月27日在深圳会展中心&#xff08;福田&#xff09;盛大开幕&#xff01;来自零售、电商、品牌等渠道的买家与专业观众&#xff0c;以及来自全…

提高LabVIEW程序可靠性

​提高LabVIEW程序的可靠性是确保系统稳定运行、减少故障和维护成本的重要措施。以下从多个方面详细分析如何提高LabVIEW程序的可靠性 1. 选择合适的架构 1.1 状态机架构 适用情况&#xff1a; 多状态、多步骤操作。 具体例子&#xff1a;在一个自动测试系统中&#xff0c;…