GITZYY 7 luni în urmă
părinte
comite
70e0dd253d
19 a modificat fișierele cu 239 adăugiri și 262 ștergeri
  1. 12 10
      egress-gateway-service-domain/pom.xml
  2. 2 2
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/resolver/payload/ApiJsonPayloadResolver.java
  3. 0 167
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/common/utils/GsonUtil.java
  4. 24 0
      egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/common/utils/GsonUtils.java
  5. 4 0
      egress-gateway-service-infrastructure/pom.xml
  6. 44 0
      egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/cache/TestCacheService.java
  7. 1 1
      egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/repository/database/entity/BaseDo.java
  8. 2 0
      egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/service/impl/EgApiEndpointServiceImpl.java
  9. 2 0
      egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/service/impl/EgApiServiceImpl.java
  10. 0 31
      egress-gateway-service-infrastructure/src/test/java/com/hrsk/cloud/op/eg/repository/CustomerMapperTest.java
  11. 0 0
      egress-gateway-service-infrastructure/src/test/resources/sample.properties
  12. 20 0
      pom.xml
  13. 5 0
      start/pom.xml
  14. 4 0
      start/src/main/java/com/hrsk/cloud/eg/Application.java
  15. 43 35
      start/src/main/resources/application-dev.yaml
  16. 36 14
      start/src/main/resources/application-pre.yaml
  17. 2 2
      start/src/main/resources/application.yaml
  18. 27 0
      start/src/test/java/StartTest.java
  19. 11 0
      start/src/test/java/TestApplication.java

+ 12 - 10
egress-gateway-service-domain/pom.xml

@@ -47,16 +47,6 @@
             <groupId>com.alibaba.cola</groupId>
             <artifactId>cola-component-exception</artifactId>
         </dependency>
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <version>${guava.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>com.google.code.gson</groupId>
-            <artifactId>gson</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-expression</artifactId>
@@ -73,5 +63,17 @@
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-pool2</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.alibaba.fastjson2</groupId>
+            <artifactId>fastjson2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 2 - 2
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/api/resolver/payload/ApiJsonPayloadResolver.java

@@ -4,7 +4,7 @@ import com.alibaba.cola.exception.BizException;
 import com.google.gson.*;
 import com.hrsk.cloud.eg.domain.api.ApiContext;
 import com.hrsk.cloud.eg.domain.api.ValueObject;
-import com.hrsk.cloud.eg.domain.common.utils.GsonUtil;
+import com.hrsk.cloud.eg.domain.common.utils.GsonUtils;
 import org.apache.commons.lang3.StringUtils;
 
 /**
@@ -29,7 +29,7 @@ public class ApiJsonPayloadResolver implements ApiPayloadResolver {
 
     @Override
     public Object resolve(String jsonTemplate, ApiContext context) {
-        JsonElement jsonElement = GsonUtil.parseJSON(jsonTemplate, JsonElement.class);
+        JsonElement jsonElement = GsonUtils.fromJson(jsonTemplate, JsonElement.class);
         traverseJson(jsonElement,jsonElement,null,context,0);
         return jsonElement.toString();
     }

+ 0 - 167
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/common/utils/GsonUtil.java

@@ -1,167 +0,0 @@
-package com.hrsk.cloud.eg.domain.common.utils;
-
-import com.google.gson.*;
-import com.google.gson.reflect.TypeToken;
-import com.hrsk.pangu.tool.exception.BizException;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author zhangyy
- * @version 1.0
- * @description: GsonUtils
- * @date 2024/8/26 18:46
- */
-public class GsonUtil {
-    private static   Gson gson =new Gson();
-    private static final Logger log = LoggerFactory.getLogger(GsonUtil.class);
-    /**
-     * @description:  对象转json字符串
-     * @author zhangyy
-     * @date 2024/8/26 18:51
-     * @version 1.0
-     */
-   private static String doToJSONString(Object obj,String  formatDate, boolean ignoreNull,
-                                       boolean pretty){
-      return getGson(formatDate,ignoreNull, pretty).toJson(obj);
-
-   }
-
-    /**
-     * 将对象转为JSON字符串。
-     * 日期转为非时间戳的格式,不忽略null值的字段,不格式化JSON字符串
-     *
-     * @param obj 被转的对象
-     * @return JSON字符串,出异常时抛出
-     */
-    public static String toJSONString(Object obj) {
-        return doToJSONString(obj, "yyyy-MM-dd HH:mm:ss", false, false);
-    }
-    /**
-     * @description: 携带参数的转化为json
-     * @author zhangyy
-     * @date 2024/8/27 14:24
-     * @version 1.0
-     */
-    public static String toJSONString(Object obj,String formatDate) {
-        return doToJSONString(obj, formatDate, false, false);
-    }
-
-    /**
-     * 获取ObjectMapper。其本身是线程安全的,可以作为成员变量,但传入的参数不可能每次都一样,所以不使用成员变量。
-     * (获取的Gson,在解析JSON字符串的时候,若字符串新增了目标类未知的字段,不报错,也就是兼容的。
-     * @param dateFormat     日期格式,传null或空串则不设置
-     * @param ignoreNull     是否忽略字段值是null的字段
-     * @param pretty         是否格式化
-     * @return
-     */
-    private static Gson getGson(String dateFormat,
-                                boolean ignoreNull,
-                                boolean pretty) {
-        GsonBuilder gsonBuilder = new GsonBuilder();
-
-        // 默认序列化的格式是 Feb 13, 2020 11:54:55 AM,如果不指定形式,改成序列化成时间戳形式
-        if (StringUtils.isNotBlank(dateFormat)) {
-            gsonBuilder.setDateFormat(dateFormat);
-        } else {
-            // 转json字符串,日期格式使用时间戳
-            gsonBuilder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
-                @Override
-                public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
-                    return new JsonPrimitive(src.getTime());
-                }
-            });
-
-            // json字符串转对象,日期格式使用时间戳的输入
-            gsonBuilder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
-                @Override
-                public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
-                    return new Date(json.getAsJsonPrimitive().getAsLong());
-                }
-            });
-        }
-
-        // 默认忽略所有null值字段
-        if (!ignoreNull) {
-            gsonBuilder.serializeNulls();
-        }
-        // 默认不格式化
-        if (pretty) {
-            gsonBuilder.setPrettyPrinting();
-        }
-        return gsonBuilder.create();
-    }
-
-    /**
-     * 传入JSON字符串,不管是对象和列表,都能兼容的方法
-     *
-     * @param jsonStr
-     * @return
-     */
-    public static <T> T parseJSON(String jsonStr, Class<T> clazz, String dateFormat) {
-        try {
-            Gson gson = getGson(dateFormat, false, false);
-            return gson.fromJson(jsonStr, clazz);
-        } catch (Exception e) {
-            throw new BizException("Invalid jsonStr,parse error:" + jsonStr, e);
-        }
-    }
-
-    /** 
-     * @description:  json字符串转对象
-     * @param:  
-     * @return:  
-     * @author zhangyy
-     * @date: 2024/8/26 19:28
-     */ 
-    public static <T> T parseJSON(String jsonStr, Class<T> clazz) {
-        try {
-            Gson gson = getGson("yyyy-MM-dd HH:mm:ss", false, false);
-            return gson.fromJson(jsonStr, clazz);
-        } catch (Exception e) {
-            throw new BizException("Invalid jsonStr,parse error:" + jsonStr, e);
-        }
-    }
-    /**
-     * json 字符串转成某个类的列表
-     *
-     * @param jsonStr    传入的JSON字串
-     * @param clazz      转为什么类型
-     * @param dateFormat 日期格式,传null或空串则不设置,不设置时默认格式化时间戳。当无法格式化的时候抛出异常
-     * @param <T>        类型
-     * @return 转换失败则抛出异常
-     */
-    public static <T> List<T> parseJSONList(String jsonStr, Class<T> clazz, String dateFormat) {
-        try {
-            Gson gson = getGson(dateFormat, false, false);
-            Type listType = TypeToken.getParameterized(ArrayList.class, clazz).getType();
-            return gson.fromJson(jsonStr, listType);
-        } catch (Exception e) {
-            throw new BizException("Invalid jsonStr,parse error:" + jsonStr, e);
-        }
-    }
-    /**
-     * json 字符串转成某个类的列表
-     *
-     * @param jsonStr    传入的JSON字串
-     * @param clazz      转为什么类型
-     * @param <T>        类型
-     * @return 转换失败则抛出异常
-     */
-    public static <T> List<T> parseJSONList(String jsonStr, Class<T> clazz) {
-        try {
-            Gson gson = getGson("yyyy-MM-dd HH:mm:ss", false, false);
-            Type listType = TypeToken.getParameterized(ArrayList.class, clazz).getType();
-            return gson.fromJson(jsonStr, listType);
-        } catch (Exception e) {
-            throw new BizException("Invalid jsonStr,parse error:" + jsonStr, e);
-        }
-    }
-
-
-}

+ 24 - 0
egress-gateway-service-domain/src/main/java/com/hrsk/cloud/eg/domain/common/utils/GsonUtils.java

@@ -0,0 +1,24 @@
+package com.hrsk.cloud.eg.domain.common.utils;
+
+import com.google.gson.Gson;
+
+/**
+ * @author: bianlanzhou
+ * @create: 2024-08-01 16:58
+ * @description: Gson工具类
+ **/
+public class GsonUtils {
+    /**
+     * gson
+     */
+    public static final Gson GSON = new Gson();
+
+    /**
+     * 转换JSON
+     * @return 实体
+     * @param <T> 范型
+     */
+    public static  <T> T fromJson(String json,Class<T> classz){
+        return GSON.fromJson(json,classz);
+    }
+}

+ 4 - 0
egress-gateway-service-infrastructure/pom.xml

@@ -55,6 +55,10 @@
             <groupId>commons-codec</groupId>
             <artifactId>commons-codec</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.alicp.jetcache</groupId>
+            <artifactId>jetcache-starter-redis</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.baomidou</groupId>
             <artifactId>mybatis-plus-boot-starter</artifactId>

+ 44 - 0
egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/cache/TestCacheService.java

@@ -0,0 +1,44 @@
+package com.hrsk.cloud.eg.infrastructure.cache;
+
+import com.alicp.jetcache.Cache;
+import com.alicp.jetcache.anno.CacheType;
+import com.alicp.jetcache.anno.CreateCache;
+import org.springframework.stereotype.Service;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author zhangyy
+ * @version 1.0
+ * @description: TestCacheService
+ * @date 2024/8/28 16:53
+ */
+@Service
+public class TestCacheService {
+
+    @CreateCache(name = "test",expire = 300,timeUnit = TimeUnit.SECONDS,cacheType = CacheType.REMOTE)
+    private Cache<String, String> cache;
+
+    /** 
+     * @description:  获取信息
+     * @param:  
+     * @return:  
+     * @author zhangyy
+     * @date: 2024/8/28 16:55
+     */ 
+    public String get(String key) {
+        return cache.get(key);
+    }
+
+    /**
+     * @description: 添加信息
+     * @param:  
+     * @return:  
+     * @author zhangyy
+     * @date: 2024/8/28 16:55
+     */ 
+    public void put(String key, String value) {
+        cache.put(key, value);
+    }
+
+}

+ 1 - 1
egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/repository/database/entity/BaseDo.java

@@ -2,6 +2,7 @@ package com.hrsk.cloud.eg.infrastructure.repository.database.entity;
 
 import com.baomidou.mybatisplus.annotation.FieldFill;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
 import lombok.Data;
 
 import java.util.Date;
@@ -16,7 +17,6 @@ public class BaseDo {
     /**
      * 主键
      */
-    @TableField(fill = FieldFill.INSERT)
     private Long id;
     /**
      * 创建人ID

+ 2 - 0
egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/service/impl/EgApiEndpointServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.hrsk.cloud.eg.infrastructure.repository.database.entity.EgApiEndpointDo;
 import com.hrsk.cloud.eg.infrastructure.repository.database.mapper.EgApiEndpointMapper;
 import com.hrsk.cloud.eg.infrastructure.service.EgApiEndpointService;
+import org.springframework.stereotype.Service;
 
 /**
  * @author zhangyy
@@ -11,6 +12,7 @@ import com.hrsk.cloud.eg.infrastructure.service.EgApiEndpointService;
  * @description: EgApiEndpointServiceImpl
  * @date 2024/8/28 11:02
  */
+@Service
 public class EgApiEndpointServiceImpl extends ServiceImpl<EgApiEndpointMapper, EgApiEndpointDo> implements EgApiEndpointService {
 
 }

+ 2 - 0
egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/service/impl/EgApiServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.hrsk.cloud.eg.infrastructure.repository.database.entity.EgApiDo;
 import com.hrsk.cloud.eg.infrastructure.repository.database.mapper.EgApiMapper;
 import com.hrsk.cloud.eg.infrastructure.service.EgApiService;
+import org.springframework.stereotype.Service;
 
 /**
  * @author zhangyy
@@ -11,5 +12,6 @@ import com.hrsk.cloud.eg.infrastructure.service.EgApiService;
  * @description: EgApiServiceImpl
  * @date 2024/8/28 11:01
  */
+@Service
 public class EgApiServiceImpl extends ServiceImpl<EgApiMapper, EgApiDo> implements EgApiService {
 }

+ 0 - 31
egress-gateway-service-infrastructure/src/test/java/com/hrsk/cloud/op/eg/repository/CustomerMapperTest.java

@@ -1,31 +0,0 @@
-package com.hrsk.cloud.op.eg.repository;
-
-
-import com.hrsk.cloud.eg.infrastructure.clinent.config.RetryRestTemplate;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.web.client.RestTemplate;
-
-
-/**
- * @description: 测试类
- * @param:  
- * @return:  
- * @author zhangyy
- * @date: 2024/8/27 14:30
- */ 
-@SpringBootTest(classes = Appendable.class)
-@RunWith(SpringRunner.class)
-public class CustomerMapperTest {
-
-
-    @Test
-    public void test() {
-        RestTemplate restTemplate = new RetryRestTemplate().restTemplate();
-        for (int i = 0; i < 100; i++) {
-            restTemplate.postForEntity("https://www.baidu.com", null, String.class);
-        }
-    }
-}

+ 0 - 0
egress-gateway-service-infrastructure/src/test/resources/sample.properties


+ 20 - 0
pom.xml

@@ -25,6 +25,9 @@
         <http.version>4.5.5</http.version>
         <common-pools.version>2.4.2</common-pools.version>
         <mybatis-plus-generator.version>3.5.1</mybatis-plus-generator.version>
+        <jetcache.version>2.7.0.M1</jetcache.version>
+        <fast2json.version>2.0.25</fast2json.version>
+        <guva.version>33.2.1-jre</guva.version>
     </properties>
 
     <dependencies>
@@ -130,6 +133,23 @@
                 <artifactId>commons-pool2</artifactId>
                 <version>${common-pools.version}</version>
             </dependency>
+            <dependency>
+                <groupId>com.alicp.jetcache</groupId>
+                <artifactId>jetcache-starter-redis</artifactId>
+                <version>${jetcache.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>com.alibaba.fastjson2</groupId>
+                <artifactId>fastjson2</artifactId>
+                <version>${fast2json.version}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>com.google.guava</groupId>
+                <artifactId>guava</artifactId>
+                <version>${guva.version}</version>
+            </dependency>
+
         </dependencies>
     </dependencyManagement>
 

+ 5 - 0
start/pom.xml

@@ -20,6 +20,11 @@
             <groupId>com.hrsk.cloud</groupId>
             <artifactId>egress-gateway-service-adapter</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>

+ 4 - 0
start/src/main/java/com/hrsk/cloud/eg/Application.java

@@ -1,6 +1,8 @@
 package com.hrsk.cloud.eg;
 
 
+import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation;
+import com.alicp.jetcache.anno.config.EnableMethodCache;
 import lombok.extern.slf4j.Slf4j;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
@@ -8,7 +10,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 
 @Slf4j
 @SpringBootApplication
+@EnableCreateCacheAnnotation
 @MapperScan("com.hrsk.cloud.eg.infrastructure.repository.database.mapper")
+@EnableMethodCache(basePackages = "com.hrsk.cloud.eg.infrastructure.cache")
 public class Application {
     /**
      * main函数

+ 43 - 35
start/src/main/resources/application-dev.yaml

@@ -1,40 +1,48 @@
 spring:
-  application:
-    name:
-  redis:
-    database: 0
-    host: 192.168.1.169
-    #    port: 6379
-    port: 6380
-    password: meloinfo2023!
-    lettuce:
-      pool:
-        max-idle: 300
-        max-active: 600
-        max-wait: 1000s
-    timeout: 5s
-    datasource:
-      druid:
-        type: com.alibaba.druid.pool.DruidDataSource
+  datasource:
+    druid:
+      type: com.alibaba.druid.pool.DruidDataSource
         #    url: jdbc:mysql://192.168.0.166:3306/loan_dev?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
-        url: jdbc:mysql://192.168.1.169:3306/loan_uat2?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
-        username: root
-        password: meloinfo2019
+      url: jdbc:mysql://192.168.1.169:3306/loan_uat2?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
+      username: root
+      password: meloinfo2019
         #url: jdbc:mysql://rm-bp1e5b4cg75f70084.mysql.rds.aliyuncs.com/loan_pre?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowMultiQueries=true
         #username: loan_uat_mast
         #password: n!OReCRXu4Y9KxKtJb
-        driver-class-name: com.mysql.jdbc.Driver
-        filters: stat
-        maxActive: 500
-        initialSize: 2
-        maxWait: 60000
-        minIdle: 1
-        timeBetweenEvictionRunsMillis: 60000
-        minEvictableIdleTimeMillis: 300000
-        validationQuery: select 1
-        testWhileIdle: true
-        testOnBorrow: false
-        testOnReturn: false
-        poolPreparedStatements: true
-        maxOpenPreparedStatements: 20
-        logSlowSql: true
+      driver-class-name: com.mysql.jdbc.Driver
+      filters: stat
+      maxActive: 500
+      initialSize: 2
+      maxWait: 60000
+      minIdle: 1
+      timeBetweenEvictionRunsMillis: 60000
+      minEvictableIdleTimeMillis: 300000
+      validationQuery: select 1
+      testWhileIdle: true
+      testOnBorrow: false
+      testOnReturn: false
+      poolPreparedStatements: true
+      maxOpenPreparedStatements: 20
+      logSlowSql: true
+jetcache:
+  statIntervalMinutes: 15
+  areaInCacheName: false
+  local:
+    default:
+      type: linkedhashmap
+      keyConvertor: fastjson
+      limit: 1000
+  remote:
+    default:
+      type: redis
+      keyConvertor: fastjson
+      valueEncoder: java
+      valueDecoder: java
+      poolConfig:
+        minIdle: 5
+        maxIdle: 20
+        maxTotal: 50
+      database: 0 # 连接工厂使用的数据库索引
+      host: 192.168.1.169 # 此处需要修改哈
+      port: 6379 # 此处需要修改哈
+      password: meloinfo2023! # 此处需要修改哈

+ 36 - 14
start/src/main/resources/application-pre.yaml

@@ -1,17 +1,4 @@
 spring:
-  application:
-    name:
-  redis:
-    database: 8
-    host: 47.96.139.31
-    port: 6380
-    password: IICdQIBA#DANB%gkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAK8f%
-    lettuce:
-      pool:
-        max-idle: 300
-        max-active: 600
-        max-wait: 1000s
-    timeout: 5s
   datasource:
     druid:
       type: com.alibaba.druid.pool.DruidDataSource
@@ -32,4 +19,39 @@ spring:
       testOnReturn: false
       poolPreparedStatements: true
       maxOpenPreparedStatements: 20
-      logSlowSql: true
+      logSlowSql: true
+jetcache:
+  statIntervalMinutes: 0 # 指定统计间隔,以分钟为单位。0表示没有统计数据。
+  areaInCacheName: true # jetcache-anno使用缓存名称作为远程缓存密钥前缀,在jetcache 2.4.3 和之前的版本中,它总是在缓存名称中添加区域名称,从2.4.4开始我们有这个配置项,为兼容原因,默认值为true。
+  local:
+    default:
+      keyConvertor: fastjson # key 通过 fastjson 转换为 json
+      type: linkedhashmap
+      poolConfig:
+        minIdle: 5 # 连接池中的最小空闲连接数
+        maxIdle: 20 # 连接池中的最大空闲连接数
+        maxTotal: 50 # 连接池中的最大连接数
+  remote:
+    default:
+      keyConvertor: fastjson # key 通过 fastjson 转换为 json
+      valueEncoder: java #全局配置值编码器只需要远程缓存。两个内置valueEncoder是java和kryo
+      valueDecoder: java #全局配置值解码器只需要远程缓存。两个内置valueEncoder是java和kryo
+      type: redis # 类型,远程缓存类型有redis和tair
+      host: 47.96.139.31 # 远程缓存地址
+      port: 6380 # 远程缓存端口
+      password: IICdQIBA#DANB%gkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAK8f% # 缓存密码
+      poolConfig:
+        minIdle: 10 # 连接池中的最小空闲连接数
+        maxIdle: 300 # 连接池中的最大空闲连接数
+        maxTotal: 100 # 连接池中的最大连接数
+#  redis:
+#    database: 8
+#    host: 47.96.139.31
+#    port: 6380
+#    password: IICdQIBA#DANB%gkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAK8f%
+#    lettuce:
+#      pool:
+#        max-idle: 300
+#        max-active: 600
+#        max-wait: 1000s
+#    timeout: 5s

+ 2 - 2
start/src/main/resources/application.yaml

@@ -6,9 +6,9 @@ server:
 #spring
 spring:
   application:
-    name: loan-server
+    name: eg-server
   profiles:
-    active: pre
+    active: dev
 #mybatis
 mybatis-plus:
   mapper-locations: classpath*:mapper/**/*.xml

+ 27 - 0
start/src/test/java/StartTest.java

@@ -0,0 +1,27 @@
+import com.hrsk.cloud.eg.Application;
+import com.hrsk.cloud.eg.infrastructure.cache.TestCacheService;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+
+/**
+ * @author zhangyy
+ * @version 1.0
+ * @description: Test
+ * @date 2024/8/28 17:03
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class StartTest {
+
+    @Resource
+    private TestCacheService testCacheService;
+    @Test
+    public void test(){
+        testCacheService.put("1","1");
+
+    }
+}

+ 11 - 0
start/src/test/java/TestApplication.java

@@ -0,0 +1,11 @@
+import com.hrsk.cloud.eg.Application;
+import org.springframework.boot.SpringApplication;
+import org.springframework.context.ApplicationContext;
+
+public class TestApplication {
+
+    public static void main(String[] args) {
+        //这里填的是TestApplication
+        ApplicationContext context = SpringApplication.run(Application.class, args);
+    }
+}