From 40d332426639ec4c61325f94c3bb759f9d75c319 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 11 Nov 2022 01:20:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Spring=20Cloud=20=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95=EF=BC=8C=E6=8F=92=E5=85=A5=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=8D=E8=BF=94=E5=9B=9E=20id=20=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-framework/yudao-common/pom.xml | 5 +++++ .../iocoder/yudao/framework/common/util/json/JsonUtils.java | 2 ++ .../src/test/resources/application-unit-test.yaml | 3 +++ .../src/test/resources/application-unit-test.yaml | 5 +++++ .../module/system/service/permission/MenuServiceTest.java | 5 +++-- .../src/test/resources/application-unit-test.yaml | 6 +++++- 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/yudao-framework/yudao-common/pom.xml b/yudao-framework/yudao-common/pom.xml index dc0c7459b..23ce31370 100644 --- a/yudao-framework/yudao-common/pom.xml +++ b/yudao-framework/yudao-common/pom.xml @@ -105,6 +105,11 @@ jackson-core provided + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + provided + org.slf4j diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java index 0be190942..86d220638 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import lombok.SneakyThrows; import lombok.experimental.UtilityClass; import lombok.extern.slf4j.Slf4j; @@ -28,6 +29,7 @@ public class JsonUtils { static { objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); + objectMapper.registerModules(new JavaTimeModule()); // 解决 LocalDateTime 的序列化 } /** diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml index 25bfe0a62..e7dcccdab 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/test/resources/application-unit-test.yaml @@ -23,6 +23,9 @@ spring: mybatis-plus: lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject + global-config: + db-config: + id-type: AUTO # H2 主键递增 --- #################### 定时任务相关配置 #################### diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml index 3a2079cdc..a37c1855d 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml +++ b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml @@ -30,6 +30,11 @@ mybatis-plus: lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject +mybatis-plus: + global-config: + db-config: + id-type: AUTO # H2 主键递增 + --- #################### 定时任务相关配置 #################### --- #################### 配置中心相关配置 #################### diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceTest.java index 5d206409b..b5d21f031 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceTest.java @@ -5,6 +5,7 @@ import cn.hutool.core.lang.Assert; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; import cn.iocoder.yudao.framework.common.util.spring.SpringAopUtils; +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.menu.MenuCreateReqVO; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.menu.MenuListReqVO; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.menu.MenuUpdateReqVO; @@ -13,13 +14,13 @@ import cn.iocoder.yudao.module.system.dal.mysql.permission.MenuMapper; import cn.iocoder.yudao.module.system.enums.permission.MenuTypeEnum; import cn.iocoder.yudao.module.system.mq.producer.permission.MenuProducer; import cn.iocoder.yudao.module.system.service.tenant.TenantService; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import com.google.common.collect.Multimap; import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; import javax.annotation.Resource; +import java.time.LocalDateTime; import java.util.*; import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet; @@ -74,7 +75,7 @@ public class MenuServiceTest extends BaseDbUnitTest { assertPojoEquals(menuDO1, permissionMenuCache.get(menuDO1.getPermission())); assertPojoEquals(menuDO2, permissionMenuCache.get(menuDO2.getPermission())); - Date maxUpdateTime = (Date) BeanUtil.getFieldValue(target, "maxUpdateTime"); + LocalDateTime maxUpdateTime = (LocalDateTime) BeanUtil.getFieldValue(target, "maxUpdateTime"); assertEquals(ObjectUtils.max(menuDO1.getUpdateTime(), menuDO2.getUpdateTime()), maxUpdateTime); } diff --git a/yudao-module-system/yudao-module-system-biz/src/test/resources/application-unit-test.yaml b/yudao-module-system/yudao-module-system-biz/src/test/resources/application-unit-test.yaml index 63ea5546d..a8417d1c2 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/resources/application-unit-test.yaml +++ b/yudao-module-system/yudao-module-system-biz/src/test/resources/application-unit-test.yaml @@ -26,10 +26,14 @@ spring: port: 16379 # 端口(单元测试,使用 16379 端口) database: 0 # 数据库索引 - mybatis: lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 +mybatis-plus: + global-config: + db-config: + id-type: AUTO # H2 主键递增 + --- #################### 定时任务相关配置 #################### --- #################### 配置中心相关配置 ####################