commit 55a722a6a20aaecdf497ff62a72378a617f1fbfb
Author: fst1996 <2411194573@qq.com>
Date: Thu Sep 14 20:54:39 2023 +0800
初始化
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..05d7c76
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,47 @@
+######################################################################
+# Build Tools
+
+.gradle
+/build/
+!gradle/wrapper/gradle-wrapper.jar
+
+target/
+!.mvn/wrapper/maven-wrapper.jar
+
+######################################################################
+# IDE
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### JRebel ###
+rebel.xml
+### NetBeans ###
+nbproject/private/
+build/*
+nbbuild/
+dist/
+nbdist/
+.nb-gradle/
+target/
+
+######################################################################
+# Others
+*.log
+*.xml.versionsBackup
+*.swp
+
+!*/build/*.java
+!*/build/*.html
+!*/build/*.xml
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..6d2e955
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,51 @@
+
+
+
+ com.bawei
+ menghang-common
+ 3.6.0
+
+ 4.0.0
+
+ menghang-common-redis
+
+ 3.6.0
+
+ menghang-common-redis缓存服务
+
+
+
+
+ menghang-public
+ 梦航-public
+ http://192.168.111.130:8081/repository/maven-public/
+
+
+
+
+
+ menghang-releases
+ 梦航-releases
+ http://192.168.111.130:8081/repository/maven-releases/
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+
+
+ com.bawei
+ menghang-common-core
+ 3.6.0
+
+
+
+
diff --git a/src/main/java/com/bawei/common/redis/configure/FastJson2JsonRedisSerializer.java b/src/main/java/com/bawei/common/redis/configure/FastJson2JsonRedisSerializer.java
new file mode 100644
index 0000000..18d9446
--- /dev/null
+++ b/src/main/java/com/bawei/common/redis/configure/FastJson2JsonRedisSerializer.java
@@ -0,0 +1,49 @@
+package com.bawei.common.redis.configure;
+
+import java.nio.charset.Charset;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.SerializationException;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONReader;
+import com.alibaba.fastjson2.JSONWriter;
+
+/**
+ * Redis使用FastJson序列化
+ *
+ * @author bawei
+ */
+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/bawei/common/redis/configure/RedisConfig.java b/src/main/java/com/bawei/common/redis/configure/RedisConfig.java
new file mode 100644
index 0000000..1d741bc
--- /dev/null
+++ b/src/main/java/com/bawei/common/redis/configure/RedisConfig.java
@@ -0,0 +1,43 @@
+package com.bawei.common.redis.configure;
+
+import org.springframework.boot.autoconfigure.AutoConfigureBefore;
+import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
+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.serializer.StringRedisSerializer;
+
+/**
+ * redis配置
+ *
+ * @author bawei
+ */
+@Configuration
+@EnableCaching
+@AutoConfigureBefore(RedisAutoConfiguration.class)
+public class RedisConfig extends CachingConfigurerSupport
+{
+ @Bean
+ @SuppressWarnings(value = { "unchecked", "rawtypes" })
+ public RedisTemplate