commit c9108cd74af0dd7e0bb48a588d5dac5d49ba2ffd
Author: liangwen <2357318727@qq.com>
Date: Sat Dec 16 16:02:50 2023 +0800
局域网minio配套服务
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..3cedd1d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,95 @@
+# Spring-minio
+MinIO 是一个基于Apache License v2.0开源协议的对象存储服务。它兼容亚马逊S3云存储服务接口,非常适合于存储大容量非结构化的数据,例如图片、视频、日志文件、备份数据和容器/虚拟机镜像等,而一个对象文件可以是任意大小,从几kb到最大5T不等。
+本项目集成Minio的java客户端SDK,对Minio文件服务器进行读写,将操作封装为MinioUtil工具,直接在项目中可以复用。其操作主要包括:
+- 上传文件
+- 下载文件
+- 读取桶列表
+- 读取桶中的文件列表
+- 删除桶
+- 删除文件
+### 著作权
+#### 匠心巨制,震撼上市
+
+
+|购买地址|
+|--|
+||
+
+### 专利文章
+| | 标题 | 技术领域 |
+|---|----|------|
+| 1 | [一种基于微服务架构的车联网大数据分析系统](https://mp.weixin.qq.com/s?__biz=Mzg5MjY3OTk0OQ==&mid=2247484096&idx=1&sn=11677bc50cd18e448135319394238e80&chksm=c03b20a2f74ca9b41c7d1c1e60e1407e1530a98b86498822f387da26e551826f8136663b45a0#rd) | 微服务|
+| 2 | [一种流式数据场景下Elasticsearch索引的自动化扩容方法](https://mp.weixin.qq.com/s?__biz=Mzg5MjY3OTk0OQ==&mid=2247484167&idx=1&sn=94587b5e196bbda2d6cc4b976b03d0c7&chksm=c03b2165f74ca873b77380a23c4e06b71adf6ffc40634440f467fb71c20aa4cc2fe72a5d65a9#rd) | 搜索引擎 |
+| 3 | [大数据钻取分析方法、装置、设备及存储介质](https://mp.weixin.qq.com/s?__biz=Mzg5MjY3OTk0OQ==&mid=2247484385&idx=1&sn=6fe4a4ac34badd91db39b4cc042a3f18&chksm=c03b2183f74ca89508333f3d5c8330aa32248eda86e4cf7657a5a293e1bf9d49888fe78b1072#rd) | 大数据分析 |
+| 4 | [一种基于工作流引擎的自动化办公方法和系统](https://mp.weixin.qq.com/s?__biz=Mzg5MjY3OTk0OQ==&mid=2247484895&idx=1&sn=1094f0b9abef603e8126dea68db75cca&chksm=c03b27bdf74caeab50d56ac110b9ab0d36bc9b9069e311083a5c4295ab03ee4b0595a00a3ba2#rd) | 工作流引擎 |
+
+
+
+### 视频教程
+
+|
|
+|--|
+| |
+
+
+### 附录:中央技术储备仓库(Central Technique Reserve Repository)
+
+#### 基础篇:职业化,从做好OA系统开始
+1. [Spring boot整合Mybatis实现增删改查(支持多数据源)](https://gitee.com/shenzhanwang/SSM)
+2. [Spring,SpringMVC和Hibernate的整合实现增删改查](https://gitee.com/shenzhanwang/SSH)
+3. [Spring boot整合activiti工作流引擎实现OA开发](https://gitee.com/shenzhanwang/Spring-activiti)
+4. [Ruoyi-boot集成工作流引擎Flowable实例](https://gitee.com/shenzhanwang/Ruoyi-flowable)
+5. [Spring发布与调用REST风格的WebService](https://gitee.com/shenzhanwang/Spring-REST)
+6. [Spring boot整合Axis调用SOAP风格的web服务](https://gitee.com/shenzhanwang/Spring-axis)
+7. [Spring boot整合Apache Shiro实现RBAC权限控制](https://gitee.com/shenzhanwang/Spring-shiro)
+8. [使用Spring security实现RBAC权限控制](https://gitee.com/shenzhanwang/spring-security-demo)
+#### 中级篇:中间件的各种姿势
+9. [Spring boot整合mongoDB文档数据库实现增删改查](https://gitee.com/shenzhanwang/Spring-mongoDB)
+10. [Spring连接Redis实现缓存](https://gitee.com/shenzhanwang/Spring-redis)
+11. [Spring连接图存数据库Neo4j实现增删改查](https://gitee.com/shenzhanwang/Spring-neo4j)
+12. Spring boot整合列存数据库hbase实现增删改查
+13. [Spring平台整合消息队列ActiveMQ实现发布订阅、生产者消费者模型(JMS)](https://gitee.com/shenzhanwang/Spring-activeMQ)
+14. [Spring boot整合消息队列RabbitMQ实现四种消息模式(AMQP)](https://gitee.com/shenzhanwang/Spring-rabbitMQ)
+15. Spring boot整合kafka 2.1.0实现大数据消息管道
+16. [Spring boot整合websocket实现即时通讯](https://gitee.com/shenzhanwang/Spring-websocket)
+17. [Spring security整合oauth2实现token认证](https://gitee.com/shenzhanwang/Spring-security-oauth2)
+18. [Spring boot整合MinIO客户端实现文件管理](https://gitee.com/shenzhanwang/Spring-minio)
+19. 23种设计模式,源码、注释、使用场景
+20. [使用ETL工具Kettle的实例](https://gitee.com/shenzhanwang/Kettle-demo)
+21. Git指南和分支管理策略
+22. 使用数据仓库进行OLAP数据分析(Mysql+Kettle+Zeppelin)
+#### 高级篇:分布式系统和大数据开发
+23. [zookeeper原理、架构、使用场景和可视化](https://gitee.com/shenzhanwang/zookeeper-practice)
+24. Spring boot整合Apache dubbo v2.7.5实现分布式服务治理(SOA架构) 
+> 包含组件Spring boot v2.2.2+Dubbo v2.7.5+Nacos v1.1.1
+效果图
+25. 使用Spring Cloud Alibaba v2.2.7实现微服务架构(MSA架构)
+> 包含组件Nacos+Feign+Gateway+Ribbon+Sentinel+Zipkin
+效果图
+26. 使用jenkins+centos+git+maven搭建持续集成环境自动化部署分布式服务
+27. 使用docker+compose+jenkins+gitlab+spring cloud实现微服务的编排、持续集成和动态扩容
+28. 使用Spark进行分布式计算
+- Spark SQL做离线计算
+- Spark Streaming做实时计算
+- Structured Streaming做实时计算
+29. 使用Flink实现流批一体化的分布式计算
+30. 搭建高可用nginx集群和Tomcat负载均衡
+31. 使用mycat实现Mysql数据库的主从复制、读写分离、分表分库、负载均衡和高可用
+32. [《Elasticsearch数据搜索与分析实战》源码](https://gitee.com/shenzhanwang/Spring-elastic_search) 
+#### 特别篇:分布式事务和并发控制
+33. 基于可靠消息最终一致性实现分布式事务(activeMQ)
+34. Spring boot dubbo整合seata实现分布式事务
+> 包含组件nacos v2.0.2 + seata v1.4.2 +spring boot dubbo v2.7.5
+效果图
+35. Spring cloud alibaba v2.2.7整合seata实现分布式事务 
+> 包含组件nacos v2.0.2 + seata v1.4.2 +spring cloud alibaba v2.2.7
+效果图
+36. 并发控制:数据库锁机制和事务隔离级别的实现
+37. 并发控制:使用redission实现分布式锁
+38. 并发控制:使用zookeeper实现分布式锁
+39. 并发控制:Java多线程编程实例
+40. 并发控制:使用netty实现高性能NIO通信
+
+### 关注微信公众号获取更多技术文章和源码
+
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..e7c7281
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,137 @@
+
+ 4.0.0
+ hb
+ hb-minio
+ 1.0
+
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+ 2.1.6.RELEASE
+
+
+ org.springframework.boot
+ spring-boot-starter
+ 2.1.6.RELEASE
+
+
+ org.springframework.boot
+ spring-boot-starter-logging
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ 2.1.6.RELEASE
+ test
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+ 2.1.6.RELEASE
+
+
+ org.springframework.boot
+ spring-boot-starter-logging
+
+
+
+
+ io.springfox
+ springfox-swagger2
+ 2.9.2
+
+
+ io.springfox
+ springfox-swagger-ui
+ 2.9.2
+
+
+ com.alibaba
+ fastjson
+ 1.2.68
+
+
+ org.springframework.boot
+ spring-boot-starter-log4j2
+ 2.1.6.RELEASE
+
+
+ org.apache.commons
+ commons-lang3
+ 3.9
+
+
+ io.minio
+ minio
+ 8.2.0
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ true
+ 2.1.6.RELEASE
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+ 2.1.8.RELEASE
+
+
+
+ redis.clients
+ jedis
+ 3.7.0
+
+
+ com.alibaba.fastjson2
+ fastjson2
+ 2.0.9
+
+
+
+ hb-minio
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 2.1.6.RELEASE
+
+ true
+
+
+
+
+ repackage
+
+
+
+
+
+
+
+
+
+ jdk-1.8
+
+ true
+ 1.8
+
+
+ 1.8
+ 1.8
+ 1.8
+
+
+
+
+ UTF-8
+
+
diff --git a/src/main/java/com/hb/Application.java b/src/main/java/com/hb/Application.java
new file mode 100644
index 0000000..95a7232
--- /dev/null
+++ b/src/main/java/com/hb/Application.java
@@ -0,0 +1,14 @@
+package com.hb;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+
+@SpringBootApplication
+public class Application {
+
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+
+}
diff --git a/src/main/java/com/hb/Swagger2.java b/src/main/java/com/hb/Swagger2.java
new file mode 100644
index 0000000..707ee61
--- /dev/null
+++ b/src/main/java/com/hb/Swagger2.java
@@ -0,0 +1,36 @@
+package com.hb;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+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;
+
+
+@Configuration
+@EnableSwagger2
+public class Swagger2 {
+ @Bean
+ public Docket createRestApi() {
+ return new Docket(DocumentationType.SWAGGER_2)
+ .apiInfo(apiInfo())
+ .select()
+ .apis(RequestHandlerSelectors.basePackage("com.hb.controller"))
+ .paths(PathSelectors.any())
+ .build();
+ }
+
+ private ApiInfo apiInfo() {
+ return new ApiInfoBuilder()
+ .title("hb minio api文档")
+ .description("minio操作API文档")
+ //.termsOfServiceUrl("http://gitee.com/shenzhanwang/projects")
+ .version("1.0")
+ .build();
+ }
+}
diff --git a/src/main/java/com/hb/config/CorsConfig.java b/src/main/java/com/hb/config/CorsConfig.java
new file mode 100644
index 0000000..e5cddc5
--- /dev/null
+++ b/src/main/java/com/hb/config/CorsConfig.java
@@ -0,0 +1,33 @@
+package com.hb.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@Configuration
+public class CorsConfig {
+
+ @Bean
+ public WebMvcConfigurer corsConfigurer() {
+ return new WebMvcConfigurer() {
+ @Override
+ //重写父类提供的跨域请求处理的接口
+ public void addCorsMappings(CorsRegistry registry) {
+ //添加映射路径
+ registry.addMapping("/**")
+ //放行哪些原始域
+ .allowedOrigins("*")
+ //是否发送Cookie信息
+ .allowCredentials(true)
+ //放行哪些原始域(请求方式)
+ .allowedMethods("GET", "POST", "PUT", "DELETE")
+ //放行哪些原始域(头部信息)
+ .allowedHeaders("*")
+ //暴露哪些头部信息(因为跨域访问默认不能获取全部头部信息)
+ .exposedHeaders("token");
+
+ }
+ };
+ }
+}
diff --git a/src/main/java/com/hb/config/FastJson2JsonRedisSerializer.java b/src/main/java/com/hb/config/FastJson2JsonRedisSerializer.java
new file mode 100644
index 0000000..a0d5cf7
--- /dev/null
+++ b/src/main/java/com/hb/config/FastJson2JsonRedisSerializer.java
@@ -0,0 +1,49 @@
+package com.hb.config;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONReader;
+import com.alibaba.fastjson2.JSONWriter;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.SerializationException;
+
+import java.nio.charset.Charset;
+
+/**
+ * Redis使用FastJson序列化
+ *
+ * @author ruoyi
+ */
+public class FastJson2JsonRedisSerializer implements RedisSerializer
+{
+ public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
+
+ private Class clazz;
+
+ public FastJson2JsonRedisSerializer(Class clazz)
+ {
+ super();
+ this.clazz = clazz;
+ }
+
+ @Override
+ public byte[] serialize(T t) throws SerializationException
+ {
+ if (t == null)
+ {
+ return new byte[0];
+ }
+ return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName).getBytes(DEFAULT_CHARSET);
+ }
+
+ @Override
+ public T deserialize(byte[] bytes) throws SerializationException
+ {
+ if (bytes == null || bytes.length <= 0)
+ {
+ return null;
+ }
+ String str = new String(bytes, DEFAULT_CHARSET);
+
+ return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType);
+ }
+}
diff --git a/src/main/java/com/hb/config/InterceptorConfig.java b/src/main/java/com/hb/config/InterceptorConfig.java
new file mode 100644
index 0000000..239f8d7
--- /dev/null
+++ b/src/main/java/com/hb/config/InterceptorConfig.java
@@ -0,0 +1,30 @@
+package com.hb.config;
+
+import com.hb.interceptor.MyInterceptor;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.*;
+
+/**
+ * @Auther: shaoming
+ * @Date: 2021/1/8 14:11
+ * @Description: 注册拦截器配置类
+ */
+@Configuration//表名这是springboot的配置类
+public class InterceptorConfig implements WebMvcConfigurer {
+ @Override
+ public void addInterceptors(InterceptorRegistry registry) {
+ //定义排除swagger访问的路径配置
+ String[] swaggerExcludes=new String[]{"/swagger-ui.html","/swagger-resources/**","/webjars/**", "/getPicture"};
+
+ registry.addInterceptor(new MyInterceptor())
+ // addPathPatterns 用于添加拦截规则
+ .addPathPatterns("/**")
+ .excludePathPatterns(swaggerExcludes);
+ WebMvcConfigurer.super.addInterceptors(registry);
+ }
+
+}
+
+
+
+
diff --git a/src/main/java/com/hb/config/MinioConfig.java b/src/main/java/com/hb/config/MinioConfig.java
new file mode 100644
index 0000000..b8180f7
--- /dev/null
+++ b/src/main/java/com/hb/config/MinioConfig.java
@@ -0,0 +1,75 @@
+package com.hb.config;
+
+import okhttp3.OkHttpClient;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.minio.MinioClient;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.security.cert.X509Certificate;
+
+@Configuration
+public class MinioConfig {
+
+ @Value("${minio.url}")
+ private String url;
+ @Value("${minio.accessKey}")
+ private String accessKey;
+ @Value("${minio.secretKey}")
+ private String secretKey;
+
+ /*@Bean
+ public MinioClient getMinioClient() {
+ MinioClient minioClient = MinioClient.builder().endpoint(url)
+ .credentials(accessKey, secretKey).build();
+ return minioClient;
+ }*/
+
+ @Bean
+ public MinioClient minioClient(){
+
+ // Create a trust manager that does not validate certificate chains
+ TrustManager[] trustAllCerts = new TrustManager[] {
+ new X509TrustManager() {
+ public X509Certificate[] getAcceptedIssuers() {
+ return new X509Certificate[0];
+ }
+
+ public void checkClientTrusted(X509Certificate[] certs, String authType) {
+ // Do nothing (trust any client certificate)
+ }
+
+ public void checkServerTrusted(X509Certificate[] certs, String authType) {
+ // Do nothing (trust any server certificate)
+ }
+ }
+ };
+
+ // Install the all-trusting trust manager
+ SSLContext sslContext = null;
+ try {
+ sslContext = SSLContext.getInstance("SSL");
+ sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // Create a custom OkHttpClient that trusts all certificates
+ OkHttpClient customHttpClient = new OkHttpClient.Builder()
+ .sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustAllCerts[0])
+ .hostnameVerifier((hostname, session) -> true)
+ .build();
+
+ // Set the custom SSLContext for MinioClient
+ return MinioClient.builder()
+ .endpoint(url)
+ .credentials(accessKey, secretKey)
+ .httpClient(customHttpClient)
+ .build();
+ }
+
+}
diff --git a/src/main/java/com/hb/config/RedisConfig.java b/src/main/java/com/hb/config/RedisConfig.java
new file mode 100644
index 0000000..3483fb8
--- /dev/null
+++ b/src/main/java/com/hb/config/RedisConfig.java
@@ -0,0 +1,69 @@
+package com.hb.config;
+
+import org.springframework.cache.annotation.CachingConfigurerSupport;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.script.DefaultRedisScript;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+/**
+ * redis配置
+ *
+ * @author ruoyi
+ */
+@Configuration
+@EnableCaching
+public class RedisConfig extends CachingConfigurerSupport
+{
+ @Bean
+ @SuppressWarnings(value = { "unchecked", "rawtypes" })
+ public RedisTemplate