【OSS对象存储】Springboot集成阿里云OSS + 私有化部署Minio

【OSS对象存储】Springboot集成阿里云OSS + 私有化部署Minio

  • 一、摘要
  • 二、POM依赖
  • 三、配置文件
  • 四、表结构设计
  • 五、代码实现
    • 5.1 代码包结构
    • 5.2 API封装
    • 5.3 增删改查
  • 六、扩展
    • 6.1 Minio配置https访问

一、摘要

  1. 掌握阿里云OSS、私有化部署Minio两种对象存储的使用方式
  2. 运用工厂+策略模式,封装OSS对象存储API,可实现动态切换
  3. Docker部署Minio

二、POM依赖

<!-- 阿里云对象存储 -->
<dependency><groupId>com.aliyun.oss</groupId><artifactId>aliyun-sdk-oss</artifactId><version>3.15.1</version>
</dependency><!-- Minio私有化对象存储 -->
<dependency><groupId>io.minio</groupId><artifactId>minio</artifactId><version>8.5.6</version>
</dependency>

三、配置文件

ai-wxapp:oss:#  strategy: ALI_OSS#  endpoint: oss-cn-beijing.aliyuncs.com#  accessKeyId: xxxxxx#  accessKeySecret: xxxxxx#  bucketName: xxxxstrategy: MinIOendpoint: http://localhost:9000accessKeyId: xxxxxxaccessKeySecret: xxxxxxbucketName: xxxx

OssConfig.java:

@Data
@Component
@RefreshScope
public class OssConfig {@Value("${ai-wxapp.oss.strategy}")private String ossStrategy;@Value("${ai-wxapp.oss.bucketName}")private String bucketName;@Value("${ai-wxapp.oss.endpoint}")private String endpoint;@Value("${ai-wxapp.oss.accessKeyId}")private String accessKeyId;@Value("${ai-wxapp.oss.accessKeySecret}")private String accessKeySecret;
}

四、表结构设计

表结构数据

CREATE TABLE `oss_file` (`id` bigint NOT NULL AUTO_INCREMENT,`file_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '文件id',`original_file_name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '原始文件名',`file_ext` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '文件扩展名',`file_path` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '文件路径',`create_by` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '创建人',`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',`update_by` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '修改人',`update_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',PRIMARY KEY (`id`),UNIQUE KEY `oss_file_unique` (`file_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='对象存储信息表';

五、代码实现

5.1 代码包结构

在这里插入图片描述

5.2 API封装

ObjectStorageEnum.java:
```java
/*** @ClassName ObjectStorageEnum* @Description 对象存储策略枚举* @Author shn* @Date 2023/11/2 18:17* @Version 1.0**/
@Getter
public enum ObjectStorageEnum {/*** 阿里云OSS对象存储*/ALI_OSS,/*** MinIO私有化对象存储*/MinIO
}

IOssFileRepository.java

public interface IOssFileRepository {OssFileEntity getByFileId(String fileId);List<OssFileEntity> getByFileIds(List<String> fileIds);void saveEntity(OssFileEntity build);
}

ObjectStorageFactory.java

/*** @ClassName ObjectStorageFactory* @Description 对象存储策略工厂* @Author shn* @Date 2023/11/2 18:23* @Version 1.0**/
@Component
public class ObjectStorageFactory implements ApplicationContextAware, InitializingBean {private ApplicationContext applicationContext;private static final Map<ObjectStorageEnum, ObjectStorage> SERVICES = new HashMap<>();/*** 根据枚举获取策略实现类实例*/public ObjectStorage getInstance(ObjectStorageEnum storageEnum) {return SERVICES.get(storageEnum);}@Overridepublic void afterPropertiesSet() {Map<String, ObjectStorage> beans = applicationContext.getBeansOfType(ObjectStorage.class);for (ObjectStorage bean : beans.values()) {SERVICES.put(bean.getStrategyEnum(), bean);}}@Overridepublic void setApplicationContext(@NotNull ApplicationContext applicationContext) throws BeansException {this.applicationContext = applicationContext;}
}

ObjectStorage.java:

/*** @ClassName ObjectStorage* @Description 对象存储接口,异常全部对外抛出* @Author shn* @Date 2023/11/2 17:51* @Version 1.0**/
public interface ObjectStorage {/*** 获取策略枚举*/ObjectStorageEnum getStrategyEnum();/*** 判断对象是否存在** @param bucketName 桶名称* @param objectName 对象存储全路径,不包含桶名称*/boolean objectExists(String bucketName, String objectName) throws Exception;/*** 上传对象** @param bucketName 桶名称* @param objectName 对象存储全路径,不包含桶名称* @param in         输入流*/void uploadObject(String bucketName, String objectName, InputStream in) throws Exception;/*** 下载对象** @param bucketName 桶名称* @param objectName 对象存储全路径,不包含桶名称*/byte[] downloadObject(String bucketName, String objectName) throws Exception;/*** 删除对象** @param bucketName 桶名称* @param objectName 对象存储全路径,不包含桶名称*/void deleteObject(String bucketName, String objectName) throws Exception;/*** 删除对象** @param bucketName  桶名称* @param objectNames 对象存储全路径,不包含桶名称*/void deleteObjects(String bucketName, List<String> objectNames);/*** 判断桶是否存在** @param bucketName 桶名称*/boolean bucketExists(String bucketName) throws Exception;/*** 创建桶** @param bucketName 桶名称*/void createBucket(String bucketName) throws Exception;/*** 删除桶** @param bucketName 桶名称*/void deleteBucket(String bucketName) throws Exception;/*** 列出桶中的对象** @param bucketName 桶名称*/List<String> listObjects(String bucketName) throws Exception;/*** 获取临时授权访问url** @param bucketName    桶名称* @param objectName    对象存储全路径,不包含桶名称* @param expireSeconds 过期时间(单位:秒)* @return java.lang.String* @author shn 2023/11/8 13:27*/String getTempAccessUrl(String bucketName, String objectName, int expireSeconds);
}

AliOssService.java

/*** @ClassName AliOssService* @Description 阿里云OSS对象存储* @Author shn* @Date 2023/11/2 18:10* @Version 1.0**/
@Slf4j
@Service("aliOssService")
public class AliOssService implements ObjectStorage {@Resourceprivate OssConfig ossConfig;/*** 获取ossClient <br>* 1)每次请求都创建一个新的ossClient <br>* 2)虽然ossClient是线程安全的,但是考虑到OssConfig支持动态刷新,所以这里没有设计为单例。<br>* 3)因此ossClient需要手动关闭* 参考:<a href="https://help.aliyun.com/zh/oss/developer-reference/initialization-3">...</a> <br>*/private OSS getOssClient() {return new OSSClientBuilder().build(ossConfig.getEndpoint(),ossConfig.getAccessKeyId(), ossConfig.getAccessKeySecret());}/*** 关闭ossClient*/private void close(OSS ossClient) {if (ossClient != null) {ossClient.shutdown();}}@Overridepublic ObjectStorageEnum getStrategyEnum() {return ObjectStorageEnum.ALI_OSS;}@Overridepublic boolean objectExists(String bucketName, String objectName) {OSS ossClient = getOssClient();try {boolean bucketExist = ossClient.doesBucketExist(bucketName);if (!bucketExist) {return false;}boolean exists = ossClient.doesObjectExist(bucketName, objectName);if (!exists) {return false;}} finally {close(ossClient);}return true;}@Overridepublic void uploadObject(String bucketName, String objectName, InputStream in) throws Exception {if (in.available() <= 0) {throw new IOException("输入流为空");}OSS ossClient = getOssClient();try {boolean bucketExist = ossClient.doesBucketExist(bucketName);if (!bucketExist) {throw new ServiceException("bucket不存在");}ossClient.putObject(bucketName, objectName, in);log.info("文件上传OSS成功,文件路径: {}", objectName);} finally {close(ossClient);in.close();}}@Overridepublic byte[] downloadObject(String bucketName, String objectName) {OSS ossClient = getOssClient();try {boolean exists = ossClient.doesObjectExist(bucketName, objectName);if (!exists) {throw new ServiceException("文件不存在");}// ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。OSSObject ossObject = ossClient.getObject(bucketName, objectName);InputStream in = ossObject.getObjectContent();// 该API默认会关闭流return IoUtil.readBytes(in);} finally {close(ossClient);}}@Overridepublic void deleteObject(String bucketName, String objectName) {OSS ossClient = getOssClient();try {// 删除文件或目录。如果要删除目录,目录必须为空。ossClient.deleteObject(bucketName, objectName);} finally {close(ossClient);}}@Overridepublic void deleteObjects(String bucketName, List<String> objectNames) {OSS ossClient = getOssClient();try {DeleteObjectsRequest request = new DeleteObjectsRequest(bucketName);request.setKeys(objectNames);// 静默删除,删除操作不返回删除结果信息,效率高,需结合业务场景选择是否开启request.setQuiet(true);ossClient.deleteObjects(request);} finally {close(ossClient);}}@Overridepublic boolean bucketExists(String bucketName) {OSS ossClient = getOssClient();try {// 判断存储空间是否存在boolean exists = ossClient.doesBucketExist(bucketName);if (!exists) {return false;}} finally {close(ossClient);}return true;}@Overridepublic void createBucket(String bucketName) {OSS ossClient = getOssClient();try {// 创建CreateBucketRequest对象。CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName);// 如果创建存储空间的同时需要指定存储类型、存储空间的读写权限、数据容灾类型, 请参考如下代码。// 此处以设置存储空间的存储类型为标准存储为例介绍。//createBucketRequest.setStorageClass(StorageClass.Standard);// 数据容灾类型默认为本地冗余存储,即DataRedundancyType.LRS。如果需要设置数据容灾类型为同城冗余存储,请设置为DataRedundancyType.ZRS。//createBucketRequest.setDataRedundancyType(DataRedundancyType.ZRS);// 设置存储空间读写权限为公共读,默认为私有。//createBucketRequest.setCannedACL(CannedAccessControlList.PublicRead);// 在支持资源组的地域创建Bucket时,您可以为Bucket配置资源组。//createBucketRequest.setResourceGroupId(rsId);// 创建存储空间ossClient.createBucket(createBucketRequest);} finally {close(ossClient);}}@Overridepublic void deleteBucket(String bucketName) {OSS ossClient = getOssClient();try {// 删除存储空间ossClient.deleteBucket(bucketName);} finally {close(ossClient);}}@Overridepublic List<String> listObjects(String bucketName) {return null;}@Overridepublic String getTempAccessUrl(String bucketName, String objectName, int expireSeconds) {OSS ossClient = getOssClient();try {boolean exists = ossClient.doesObjectExist(bucketName, objectName);if (!exists) {throw new ServiceException("文件不存在");}String url = ossClient.generatePresignedUrl(bucketName, objectName, DateUtil.offsetSecond(new Date(), expireSeconds)).toString();return StringUtil.replaceHttp2Https(url);} finally {close(ossClient);}}
}

MinIoService.java:

@Slf4j
@Service("minIoService")
public class MinIoService implements ObjectStorage {@Resourceprivate OssConfig ossConfig;/*** 获取 MinioClient,每次请求都创建一个新的 MinioClient*/private MinioClient getMinioClient() {return MinioClient.builder().endpoint(ossConfig.getEndpoint()).credentials(ossConfig.getAccessKeyId(), ossConfig.getAccessKeySecret()).build();}@Overridepublic ObjectStorageEnum getStrategyEnum() {return ObjectStorageEnum.MinIO;}@SneakyThrows(Exception.class)@Overridepublic boolean objectExists(String bucketName, String objectName) {return false;}@SneakyThrows(Exception.class)@Overridepublic void uploadObject(String bucketName, String objectName, InputStream in) {if (in.available() <= 0) {throw new IOException("输入流为空");}try {getMinioClient().putObject(PutObjectArgs.builder().bucket(bucketName).object(objectName).stream(in, in.available(), -1).build());log.info("文件上传Minio成功,文件路径: {}", objectName);} finally {in.close();}}@SneakyThrows(Exception.class)@Overridepublic byte[] downloadObject(String bucketName, String objectName) {InputStream in = getMinioClient().getObject(GetObjectArgs.builder().bucket(bucketName).object(objectName).build());// 该API默认会关闭流return IoUtil.readBytes(in);}@SneakyThrows(Exception.class)@Overridepublic void deleteObject(String bucketName, String objectName) {getMinioClient().removeObject(RemoveObjectArgs.builder().bucket(bucketName).object(objectName).build());}@SneakyThrows(Exception.class)@Overridepublic void deleteObjects(String bucketName, List<String> objectNames) {if (CollectionUtil.isEmpty(objectNames)) {return;}getMinioClient().removeObjects(RemoveObjectsArgs.builder().bucket(bucketName).objects(objectNames.stream().map(DeleteObject::new).collect(Collectors.toList())).build());}@SneakyThrows(Exception.class)@Overridepublic boolean bucketExists(String bucketName) {return getMinioClient().bucketExists(BucketExistsArgs.builder().bucket(bucketName).build());}@SneakyThrows(Exception.class)@Overridepublic void createBucket(String bucketName) {MinioClient minioClient = getMinioClient();boolean exist = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build());if (!exist) {minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build());}}@SneakyThrows(Exception.class)@Overridepublic void deleteBucket(String bucketName) {getMinioClient().removeBucket(RemoveBucketArgs.builder().bucket(bucketName).build());}@SneakyThrows(Exception.class)@Overridepublic List<String> listObjects(String bucketName) {return null;}@SneakyThrows(Exception.class)@Overridepublic String getTempAccessUrl(String bucketName, String objectName, int expireSeconds) {String url = getMinioClient().getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder().method(Method.GET).bucket(bucketName).object(objectName).expiry(expireSeconds).build());log.info("Minio origin url: {}", url);return url;}
}

5.3 增删改查

OssFileEntity.java:

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class OssFileEntity {private String fileId;private String originalFileName;private String fileExt;private String filePath;
}
IOssFileService.java
```java
public interface IOssFileService {OssFileEntity getByFileId(String fileId);byte[] downloadFile(String fileId) throws Exception;void deleteFiles(List<String> fileIds);String uploadFile(byte[] fileBytes, String originalFileName);String getTempAccessUrl(String fileId, int expireSeconds);}

OssFileService.java

@Slf4j
@Service
public class OssFileService implements IOssFileService {@Resourceprivate OssConfig ossConfig;@Resourceprivate ObjectStorageFactory objectStorageFactory;@Resourceprivate RedisUtils redisUtils;@Resourceprivate IOssFileRepository ossFileRepository;private ObjectStorage getObjectStorage() {return objectStorageFactory.getInstance(ObjectStorageEnum.valueOf(ossConfig.getOssStrategy()));}public OssFileEntity getByFileId(String fileId) {OssFileEntity entity = ossFileRepository.getByFileId(fileId);if (entity == null) {throw new ServiceException(CommonError.OSS_FILE_NOT_EXIST);}return entity;}public byte[] downloadFile(String fileId) throws Exception {OssFileEntity entity = getByFileId(fileId);return getObjectStorage().downloadObject(ossConfig.getBucketName(), entity.getFilePath());}public void deleteFiles(List<String> fileIds) {List<OssFileEntity> list = ossFileRepository.getByFileIds(fileIds);if (CollectionUtil.isEmpty(list)) {return;}getObjectStorage().deleteObjects(ossConfig.getBucketName(),list.stream().map(OssFileEntity::getFilePath).collect(Collectors.toList()));}/*** 文件上传oss** @param fileBytes        文件* @param originalFileName 文件原始名称* @return java.lang.String 文件id* @author shn 2023/12/13 11:42*/public String uploadFile(byte[] fileBytes, String originalFileName) {if (ArrayUtil.isEmpty(fileBytes)|| StringUtils.isBlank(originalFileName)) {throw new ServiceException(CommonError.OSS_FILE_UPLOAD_ERROR);}// 上传ossString fileId = this.generateFileId();String fileExtension = FileUtil.getFileExtension(originalFileName);String filePath = buildFilePath(fileId, fileExtension);try {InputStream inputStream = new ByteArrayInputStream(fileBytes);getObjectStorage().uploadObject(ossConfig.getBucketName(), filePath, inputStream);} catch (Exception e) {log.error("文档上传失败", e);throw new ServiceException(CommonError.OSS_FILE_UPLOAD_ERROR);}// 保存数据库ossFileRepository.saveEntity(OssFileEntity.builder().fileId(fileId).originalFileName(originalFileName).fileExt(fileExtension).filePath(filePath).build());return fileId;}/*** 获取临时url** @param fileId        文件id* @param expireSeconds 过期时间(秒)* @return java.lang.String* @author shn 2024/05/29 15:36*/public String getTempAccessUrl(String fileId, int expireSeconds) {OssFileEntity entity = getByFileId(fileId);// 先查缓存String key = String.format(RedisKeys.OSS_FILE_URL_KEY, fileId);if (redisUtils.hasKey(key) && redisUtils.getExpire(key) > 0L) {return String.valueOf(redisUtils.get(key));}// 缓存不存在,则从OSS获取临时URL。设置OSS过期时间比 Redis晚2秒,保证 URL一直可用。String url = getObjectStorage().getTempAccessUrl(ossConfig.getBucketName(), entity.getFilePath(), expireSeconds + 2);// 保存临时URL到RedisredisUtils.set(key, url, expireSeconds, TimeUnit.SECONDS);return url;}/*** 构建文件存储路径*/@NotNullprivate static String buildFilePath(String fileId, String fileExtension) {return DateUtil.today() + "/" + fileId + fileExtension;}/*** 生成文件id*/private String generateFileId() {String fileId = "file_" + IdUtil.simpleUUID();log.info("generate new file id: {}", fileId);return fileId;}
}

六、扩展

6.1 Minio配置https访问

目标:实现https域名访问minio控制台、资源
步骤:
1)前往阿里云下载Apache证书文件
在这里插入图片描述
2)修改公钥和私钥文件名为private.key、public.crt 并上传至服务端
在这里插入图片描述
3)Nginx配置

upstream minio_s3 {#least_conn;server 127.0.0.1:9000;
}upstream minio_console {#least_conn;server 127.0.0.1:9001;
}server {listen 80;server_name huiling.xxxx.com;listen 443 ssl;server_name huiling.xxxx.com;# SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则# error_page 404/404.html;ssl_certificate     /etc/nginx/ssl/huiling/huiling.xxxx.com.pem;  # pem文件的路径ssl_certificate_key  /etc/nginx/ssl/huiling/huiling.xxxx.com.key; # key文件的路径ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;ssl_prefer_server_ciphers on;ssl_session_cache shared:SSL:10m;ssl_session_timeout 10m;# error_page 497  https://$host$request_uri;proxy_buffering off;proxy_request_buffering off;location / {client_max_body_size 10m;proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;proxy_connect_timeout 300;# Default is HTTP/1, keepalive is only enabled in HTTP/1.1proxy_http_version 1.1;proxy_set_header Connection "";chunked_transfer_encoding off;proxy_pass https://minio_s3; # This uses the upstream directive definition to load balance}location /minio/ui/ {rewrite ^/minio/ui/(.*) /$1 break;proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;proxy_set_header X-NginX-Proxy true;# This is necessary to pass the correct IP to be hashedreal_ip_header X-Real-IP;proxy_connect_timeout 300;# To support websockets in MinIO versions released after January 2023proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";# Some environments may encounter CORS errors (Kubernetes + Nginx Ingress)# Uncomment the following line to set the Origin request to an empty string# proxy_set_header Origin '';chunked_transfer_encoding off;proxy_pass https://minio_console; # This uses the upstream directive definition to load balance}
}

4)Docker启动配置

# 定义compose语义版本
version: '3.8'
# 定义服务
services:minio:image: minio/minio:latestcontainer_name: miniorestart: unless-stoppedcommand: server /data --console-address ":9001" -address ":9000"environment:TZ: Asia/ShanghaiLANG: en_US.UTF-8MINIO_SERVER_URL: https://huiling.xxx.comMINIO_BROWSER_REDIRECT_URL: https://huiling.xxx.com/minio/uiMINIO_ROOT_USER: minioadminMINIO_ROOT_PASSWORD: minioadmin9339volumes:- "/usr/local/docker/minio/data:/data"- "/usr/local/docker/minio/config:/root/.minio"ports:- "9000:9000"- "9001:9001"

5)验证
在这里插入图片描述

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

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

相关文章

Blender 4.2 安装GIS插件步骤

Blender 4 更新以后插件安装变得复杂&#xff0c;插件界面的安装按钮不显示&#xff0c;界面布局改变&#xff0c;怎么安装插件&#xff1a; 1. 在线安装&#xff1a; “编辑”&#xff08;Edit&#xff09;>进入偏好设置&#xff08;Preferences setting&#xff09;>…

机械学习—零基础学习日志(高数10——函数图形)

零基础为了学人工智能&#xff0c;真的开始复习高数 函数图像&#xff0c;开始新的学习&#xff01;本次就多做一做题目&#xff01; 第一题&#xff1a; 这个解法是有点不太懂的了。以后再多研究一下。再出一道题目。 张宇老师&#xff0c;比较多提示了大家&#xff0c;一定…

设计模式12-构建器

设计模式12-构建器 由来和动机原理思想构建器模式的C代码实现构建器模式中的各个组件详解1. 产品类&#xff08;Product&#xff09;2. 构建类&#xff08;Builder&#xff09;3. 具体构建类&#xff08;ConcreteBuilder&#xff09;4. 指挥者类&#xff08;Director&#xff0…

kettle从入门到精通 第七十九课 ETL之kettle kettle读取数据库BLOB字段转换为文件

上一课我们讲解了如何将文件以二进制流的方式写入数据库&#xff0c;本节课我们一起学习下如何将二进制数据读取为文件。 1、将二进制流转换为文件这里主要用到了步骤【文本文件输出】。表输入步骤从表中读取blob字段&#xff0c;java代码定义二进制流转换为文件的全路径&#…

Apache Tomcat文件包含漏洞复现(详细教程)

1.漏洞原理 Tomcat 服务器是一个免费的开放源代码的Web 应用服务器&#xff0c;其安装后会默认开启ajp连接器&#xff0c;方便与其他web服务器通过ajp协议进行交互。属于轻量级应用服务器&#xff0c;在中小型系统和并发访问用户不是很多的场合下被普遍使用&#xff0c;是开发和…

设计模式13-单件模式

设计模式13-单件模式 写在前面对象性能模式典型模式1. 单例模式&#xff08;Singleton Pattern&#xff09;2. 享元模式&#xff08;Flyweight Pattern&#xff09;3. 原型模式&#xff08;Prototype Pattern&#xff09;4. 对象池模式&#xff08;Object Pool Pattern&#xf…

【Django】在vscode中新建Django应用并新增路由

文章目录 打开一个终端输入新建app命令在app下的views.py内写一个视图app路由引入该视图项目路由引入app路由项目(settings.py)引入app&#xff08;AntappConfig配置类&#xff09;运行项目 打开一个终端 输入新建app命令 python manage.py startapp antapp在app下的views.py内…

源代码加密软件有什么用?源代码怎么防泄密

在软件开发领域&#xff0c;源代码被视为软件的生命线&#xff0c;它包含了实现特定功能的算法、业务逻辑以及技术细节&#xff0c;是软件公司的核心竞争力所在。由于源代码的重要性&#xff0c;其安全防护变得尤为关键。一旦源代码泄露&#xff0c;企业不仅面临财务损失&#…

DevExpress WinForms自动表单布局,创建高度可定制用户体验(二)

使用DevExpress WinForms的表单布局组件可以创建高度可定制的应用程序用户体验&#xff0c;从自动安排UI控件到按比例调整大小&#xff0c;DevExpress布局和数据布局控件都可以让您消除与基于像素表单设计相关的麻烦。 P.S&#xff1a;DevExpress WinForms拥有180组件和UI库&a…

【JavaEE初阶】线程的概念及创建

目录 &#x1f4d5; 前言 &#x1f4d5; 认识线程&#xff08;Thread&#xff09; &#x1f6a9; 概念 &#x1f60a;线程是什么 &#x1f642; 为啥要有线程 &#x1f62d; 进程和线程的区别&#xff08;面试题重点&#xff09; &#x1f92d; Java的线程和操作系统线程…

【学习笔记】无人机系统(UAS)的连接、识别和跟踪(八)-无人机探测与避让(DAA)机制

目录 引言 5.6 探测与避让&#xff08;DAA&#xff09;机制 5.6.1 基于PC5的探测与避让&#xff08;DAA&#xff09;机制 引言 3GPP TS 23.256 技术规范&#xff0c;主要定义了3GPP系统对无人机&#xff08;UAV&#xff09;的连接性、身份识别、跟踪及A2X&#xff08;Airc…

华为AR6300S路由器开启SSH远程登录

登录华为路由器&#xff1a; 使用控制台线连接到路由器的控制台端口或者通过Telnet或Web界面远程登录到设备。进入系统视图&#xff1a; 输入system-view&#xff08;或者简写为sys&#xff09;命令进入系统视图模式&#xff0c;这是配置全局参数的地方。生成RSA密钥对&#x…

2024年7月27日(星期六)骑行小河边村

2024年7月27日 (星期六&#xff09;骑行小河边村&#xff0c;早8:30到9:00&#xff0c;大观公园门口集合&#xff0c;9:00准时出发【因迟到者&#xff0c;骑行速度快者&#xff0c;可自行追赶偶遇。】 偶遇地点:大观公园门口集合 &#xff0c;家住东&#xff0c;西&#xff0…

NodeRed测试modbus RTU或modbus TCP通讯

目录标题 STEP1 添加modbus节点STEP2 查看是否安装成功STEP3 modbusTCP读取写入设置读取设置写入设置 STEP4 读写测试 STEP1 添加modbus节点 节点管理——控制板——安装 找到node-red-contrib-modbus&#xff0c;点击安装 STEP2 查看是否安装成功 安装成功后&#xff0c;左…

30.【C语言】函数系列下

1.嵌套调用 *定义&#xff1a;函数之间的互相调用 *例&#xff1a; int function1(int a, int b) {function2(b);//嵌套函数的调用return a; } //注意&#xff1a;不能将function2定义在function1的里面&#xff0c;这不叫嵌套函数的调用 void function2(int c) {} #include…

linux系统安装python3和pip

一、安装python 1、安装依赖环境 yum install gcc -y yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel yum install zlib zlib-devel openssl -y yum install openssl…

学习记录day16—— 数据结构 双向链表 循环链表

双向链表 1、概念 1&#xff09;就是从任意一个节点既能存储其前驱节点&#xff0c;又能存储后继节点 2)结构体中增加一个指向前驱节点的指针 //定义数据类型 typedef int datatype;//定义节点类型 typedef struct Node {union {int len;datatype data;};struct Node *prio; …

Nova Admin - 简洁干净、免费开源的后台管理系统,基于Vue3 / Vite5 / Typescript / Naive UI 等前端开发技术栈

今天看到一款 Vue3 后台管理 admin 系统&#xff0c;研究了一下发现很不错&#xff0c;推荐给大家。 Nova-admin 是一个颜值在线&#xff0c;风格清新、简洁干净后台管理模板&#xff0c;包含了平时常用的管理后台功能页面模板。基础的 UI 组件基于我之前推荐的 naive-ui 开发…

百度,有道,谷歌翻译API

API翻译 百度&#xff0c;有道&#xff0c;谷歌API翻译&#xff08;只针对中英相互翻译&#xff09;,其他语言翻译需要对应from&#xff0c;to的code 百度翻译 package fills.tools.translate; import java.util.ArrayList; import java.util.HashMap; import java.util.Lis…

ABAP+从SAP发出去的PDF文件在第三方系统出现乱码

这是一个 ABAP转换PDF调用函数CALL FUNCTION CONVERT_OTF的问题记录&#xff0c;关乎字体STSong-Light-ldentity-H 和 STSong-Light的区别 背景&#xff1a; 做了一个增强&#xff0c;是采购订单审批后自动发送采购订单PDF1到企业微信&#xff0c;用户再将企业微信收到的P…