From 6a6e95fcb65d0cf3d3d9d8c83685b2469888bfe8 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 19 Jan 2024 22:13:55 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E2=9C=A8=20=E5=AF=B9=E9=BD=90=20BOOT=20?= =?UTF-8?q?=E4=B8=8E=20CLOUD=20=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/config/SecurityConfiguration.java | 1 - .../promotion/service/coupon/CouponServiceImpl.java | 2 +- .../app/point/vo/AppMemberPointRecordRespVO.java | 2 +- .../pay/service/channel/PayChannelServiceTest.java | 2 +- .../api/logger/dto/OperateLogV2CreateReqDTO.java | 2 +- yudao-server/src/main/resources/application-dev.yaml | 10 +--------- yudao-server/src/main/resources/application-local.yaml | 1 - 7 files changed, 5 insertions(+), 15 deletions(-) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/SecurityConfiguration.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/SecurityConfiguration.java index e9ba581bf..1a6f2d7bf 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/SecurityConfiguration.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/SecurityConfiguration.java @@ -6,7 +6,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; /** * Infra 模块的 Security 配置 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java index 0f8d54966..51f1d2201 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponServiceImpl.java @@ -70,7 +70,7 @@ public class CouponServiceImpl implements CouponService { throw exception(COUPON_STATUS_NOT_UNUSED); } // 校验有效期;为避免定时器没跑,实际优惠劵已经过期 - if (LocalDateTimeUtils.isBetween(coupon.getValidStartTime(), coupon.getValidEndTime())) { + if (!LocalDateTimeUtils.isBetween(coupon.getValidStartTime(), coupon.getValidEndTime())) { throw exception(COUPON_VALID_TIME_NOT_NOW); } } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/vo/AppMemberPointRecordRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/vo/AppMemberPointRecordRespVO.java index ec95b2e02..51bbe7b00 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/vo/AppMemberPointRecordRespVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/point/vo/AppMemberPointRecordRespVO.java @@ -10,7 +10,7 @@ import java.time.LocalDateTime; public class AppMemberPointRecordRespVO { @Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "31457") - private Long id;; + private Long id; @Schema(description = "积分标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜") private String title; diff --git a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java index e8840d42e..64ad3c482 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/test/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceTest.java @@ -197,7 +197,7 @@ public class PayChannelServiceTest extends BaseDbUnitTest { channelMapper.insert(dbChannel);// @Sql: 先插入出一条存在的数据 // 准备参数 Long appId = dbChannel.getAppId(); - String code = dbChannel.getCode();; + String code = dbChannel.getCode(); // 调用 PayChannelDO channel = channelService.getChannelByAppIdAndCode(appId, code); diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/OperateLogV2CreateReqDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/OperateLogV2CreateReqDTO.java index e8c7616a4..eed1df133 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/OperateLogV2CreateReqDTO.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/OperateLogV2CreateReqDTO.java @@ -6,7 +6,7 @@ import jakarta.validation.constraints.NotNull; import lombok.Data; /** - * 系统操作日志 Create Req BO + * 系统操作日志 Create Request DTO * * @author HUIHUI */ diff --git a/yudao-server/src/main/resources/application-dev.yaml b/yudao-server/src/main/resources/application-dev.yaml index 3358e678e..8caf15b08 100644 --- a/yudao-server/src/main/resources/application-dev.yaml +++ b/yudao-server/src/main/resources/application-dev.yaml @@ -201,12 +201,4 @@ justauth: cache: type: REDIS prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: - timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 -wx: - mp: - useRedis: false - defaultContent: \u60A8\u597D\uFF0C\u6709\u4EC0\u4E48\u95EE\u9898\uFF1F - redisConfig: - host: 127.0.0.1 - port: 6379 - password: + timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 \ No newline at end of file diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index 8d3198c53..f5e300c51 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -262,7 +262,6 @@ justauth: client-id: ${wx.mp.app-id} client-secret: ${wx.mp.secret} ignore-check-redirect-uri: true - cache: type: REDIS prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: From fcef0f7f504829f3ff4463735f21111329379085 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 19 Jan 2024 22:40:59 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E2=9C=A8=20=E5=8D=87=E7=BA=A7=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- yudao-dependencies/pom.xml | 40 +++++++++---------- .../yudao-spring-boot-starter-mybatis/pom.xml | 7 ---- 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/pom.xml b/pom.xml index df8fc2c6f..bc7e85e9c 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ 1.5.0 1.18.30 - 3.2.0 + 3.2.1 1.5.5.Final UTF-8 diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index 7d9faa8a8..2096c8235 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -17,47 +17,47 @@ 2.0.0-snapshot 1.5.0 - 3.2.0 + 3.2.1 2.2.0 4.3.0 - 1.2.20 - 3.5.4.1 - 3.5.4.1 - 4.2.0 - 1.4.8.1 - 3.25.0 + 1.2.21 + 3.5.5 + 3.5.5 + 4.3.0 + 1.4.10 + 3.26.0 8.1.3.62 2.2.3 - 2.2.5 + 2.2.7 2.1.0 9.0.0 - 3.1.8 + 3.2.1 0.33.0 - 8.0.0.RELEASE - 1.0.12 + 8.0.1.RELEASE + 1.0.13 5.2.0 - 7.0.0 + 7.0.1 2.0.3 - 1.17.1 + 1.17.2 1.18.30 1.5.5.Final - 5.8.23 - 6.0.0-M8 + 5.8.25 + 6.0.0-M10 3.3.3 2.3 1.0.5 1.2.83 - 32.1.3-jre + 33.0.0-jre 5.1.0 - 2.14.4 + 2.14.5 3.10.0 0.1.55 2.9.1 @@ -66,15 +66,15 @@ 3.5.0 4.11.0 - 2.11.0 - 8.5.6 + 2.15.1 + 8.5.7 4.6.4 2.2.1 3.1.880 2.0.5 1.6.6-beta2 2.12.2 - 4.5.7.B + 4.6.0 2.2.9 diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/pom.xml b/yudao-framework/yudao-spring-boot-starter-mybatis/pom.xml index f7f4adcbb..92e85f628 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/pom.xml @@ -77,13 +77,6 @@ com.github.yulichang mybatis-plus-join-boot-starter - - - - org.mybatis - mybatis-spring - 3.0.3 - From 499134cfa2f1999f709273d1f800bfc428758488 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 20 Jan 2024 00:20:51 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E2=9C=A8=20=E9=99=8D=E4=BD=8E=20podam=20?= =?UTF-8?q?=E5=88=B0=207.2.11=EF=BC=8C=E8=A7=A3=E5=86=B3=20Spring=20Boot?= =?UTF-8?q?=202.X=20=E5=8D=95=E6=B5=8B=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-dependencies/pom.xml | 2 +- .../framework/test/core/ut/BaseDbAndRedisUnitTest.java | 3 ++- .../service/db/DataSourceConfigServiceImplTest.java | 9 ++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index 9ea907717..38799dd7e 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -40,7 +40,7 @@ 2.7.15 0.33.0 - 8.0.1.RELEASE + 7.2.11.RELEASE 1.0.13 4.11.0 diff --git a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbAndRedisUnitTest.java b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbAndRedisUnitTest.java index f5de235f6..48a179006 100644 --- a/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbAndRedisUnitTest.java +++ b/yudao-framework/yudao-spring-boot-starter-test/src/main/java/cn/iocoder/yudao/framework/test/core/ut/BaseDbAndRedisUnitTest.java @@ -8,6 +8,7 @@ import cn.iocoder.yudao.framework.test.config.SqlInitializationTestConfiguration import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; import org.redisson.spring.starter.RedissonAutoConfiguration; +import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; @@ -40,8 +41,8 @@ public class BaseDbAndRedisUnitTest { // Redis 配置类 RedisTestConfiguration.class, // Redis 测试配置类,用于启动 RedisServer -// RedisAutoConfiguration.class, // Spring Redis 自动配置类 YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 + RedisAutoConfiguration.class, // Spring Redis 自动配置类 RedissonAutoConfiguration.class, // Redisson 自动高配置类 }) public static class Application { diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java index d5bc5c5a6..1c34679a3 100755 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java @@ -9,7 +9,7 @@ import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigSaveReqVO; import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO; import cn.iocoder.yudao.module.infra.dal.mysql.db.DataSourceConfigMapper; -import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty; +import com.baomidou.dynamic.datasource.creator.DataSourceProperty; import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -61,8 +61,11 @@ public class DataSourceConfigServiceImplTest extends BaseDbUnitTest { // mock DynamicDataSourceProperties when(dynamicDataSourceProperties.getPrimary()).thenReturn("primary"); - when(dynamicDataSourceProperties.getDatasource()).thenReturn(MapUtil.of("primary", - new DataSourceProperty().setUrl("http://localhost:3306").setUsername("yunai").setPassword("tudou"))); + DataSourceProperty dataSourceProperty = new DataSourceProperty(); + dataSourceProperty.setUrl("http://localhost:3306"); + dataSourceProperty.setUsername("yunai"); + dataSourceProperty.setPassword("tudou"); + when(dynamicDataSourceProperties.getDatasource()).thenReturn(MapUtil.of("primary", dataSourceProperty)); } @Test From 5e8988b73bc76fcbc6e49b2b0a3e3c2b3b922b22 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 20 Jan 2024 00:42:46 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E2=9C=A8=20=E5=A2=9E=E5=8A=A0=20jakartaPac?= =?UTF-8?q?kage=20=E6=A0=87=E8=AF=86=EF=BC=8C=E7=BB=9F=E4=B8=80=20Spring?= =?UTF-8?q?=20Boot=202.X=20=E5=92=8C=203.X=20=E4=BB=A3=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=9A=84=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/codegen/inner/CodegenEngine.java | 18 ++++++++++++++++-- .../codegen/java/controller/controller.vm | 8 ++++---- .../codegen/java/controller/vo/saveReqVO.vm | 2 +- .../resources/codegen/java/service/service.vm | 2 +- .../codegen/java/service/serviceImpl.vm | 2 +- .../resources/codegen/java/test/serviceTest.vm | 4 ++-- .../inner/CodegenEngineAbstractTest.java | 2 ++ 7 files changed, 27 insertions(+), 11 deletions(-) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java index a7e4f5d3c..d70452e22 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java @@ -7,6 +7,7 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.extra.template.TemplateConfig; import cn.hutool.extra.template.TemplateEngine; import cn.hutool.extra.template.engine.velocity.VelocityEngine; +import cn.hutool.system.SystemUtil; import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageParam; @@ -35,10 +36,11 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableTable; import com.google.common.collect.Maps; import com.google.common.collect.Table; -import org.springframework.stereotype.Component; - import jakarta.annotation.PostConstruct; import jakarta.annotation.Resource; +import lombok.Setter; +import org.springframework.stereotype.Component; + import java.util.*; import static cn.hutool.core.map.MapUtil.getStr; @@ -156,6 +158,15 @@ public class CodegenEngine { @Resource private CodegenProperties codegenProperties; + /** + * 是否使用 jakarta 包,用于解决 Spring Boot 2.X 和 3.X 的兼容性问题 + * + * true - 使用 jakarta.validation.constraints.* + * false - 使用 javax.validation.constraints.* + */ + @Setter // 允许设置的原因,是因为单测需要手动改变 + private Boolean jakartaEnable; + /** * 模板引擎,由 hutool 实现 */ @@ -170,6 +181,8 @@ public class CodegenEngine { TemplateConfig config = new TemplateConfig(); config.setResourceMode(TemplateConfig.ResourceMode.CLASSPATH); this.templateEngine = new VelocityEngine(config); + // 设置 javaxEnable,按照是否使用 JDK17 来判断 + this.jakartaEnable = SystemUtil.getJavaInfo().isJavaVersionAtLeast(1700); // 17.00 * 100 } @PostConstruct @@ -179,6 +192,7 @@ public class CodegenEngine { globalBindingMap.put("basePackage", codegenProperties.getBasePackage()); globalBindingMap.put("baseFrameworkPackage", codegenProperties.getBasePackage() + '.' + "framework"); // 用于后续获取测试类的 package 地址 + globalBindingMap.put("jakartaPackage", jakartaEnable ? "jakarta" : "javax"); // 全局 Java Bean globalBindingMap.put("CommonResultClassName", CommonResult.class.getName()); globalBindingMap.put("PageResultClassName", PageResult.class.getName()); diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/controller.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/controller.vm index f58ce0cb2..32d00c7a5 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/controller.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/controller.vm @@ -1,7 +1,7 @@ package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}; import org.springframework.web.bind.annotation.*; -import jakarta.annotation.Resource; +import ${jakartaPackage}.annotation.Resource; import org.springframework.validation.annotation.Validated; #if ($sceneEnum.scene == 1)import org.springframework.security.access.prepost.PreAuthorize;#end @@ -9,9 +9,9 @@ import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Operation; -import jakarta.validation.constraints.*; -import jakarta.validation.*; -import jakarta.servlet.http.*; +import ${jakartaPackage}.validation.constraints.*; +import ${jakartaPackage}.validation.*; +import ${jakartaPackage}.servlet.http.*; import java.util.*; import java.io.IOException; diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm index e6d96fbab..b432c7527 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm @@ -3,7 +3,7 @@ package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePac import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.*; -import jakarta.validation.constraints.*; +import ${jakartaPackage}.validation.constraints.*; ## 处理 BigDecimal 字段的引入 #foreach ($column in $columns) #if (${column.javaType} == "BigDecimal") diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/service.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/service.vm index 828cabdf1..c4ee4f0f6 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/service.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/service.vm @@ -1,7 +1,7 @@ package ${basePackage}.module.${table.moduleName}.service.${table.businessName}; import java.util.*; -import jakarta.validation.*; +import ${jakartaPackage}.validation.*; import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*; import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; ## 特殊:主子表专属逻辑 diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/serviceImpl.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/serviceImpl.vm index 4d7070926..a8184e4d7 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/serviceImpl.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/serviceImpl.vm @@ -1,7 +1,7 @@ package ${basePackage}.module.${table.moduleName}.service.${table.businessName}; import org.springframework.stereotype.Service; -import jakarta.annotation.Resource; +import ${jakartaPackage}.annotation.Resource; import org.springframework.validation.annotation.Validated; import org.springframework.transaction.annotation.Transactional; diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/test/serviceTest.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/test/serviceTest.vm index f72945064..bfd4600f5 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/test/serviceTest.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/test/serviceTest.vm @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; -import jakarta.annotation.Resource; +import ${jakartaPackage}.annotation.Resource; import ${baseFrameworkPackage}.test.core.ut.BaseDbUnitTest; @@ -13,7 +13,7 @@ import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.business import ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper; import ${PageResultClassName}; -import jakarta.annotation.Resource; +import ${jakartaPackage}.annotation.Resource; import org.springframework.context.annotation.Import; import java.util.*; import java.time.LocalDateTime; diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java index 5176af1c7..3c7390abe 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineAbstractTest.java @@ -45,7 +45,9 @@ public abstract class CodegenEngineAbstractTest extends BaseMockitoUnitTest { @BeforeEach public void setUp() { + codegenEngine.setJakartaEnable(true); // 强制使用 jakarta,保证单测可以基于 jakarta 断言 codegenEngine.initGlobalBindingMap(); + // 单测强制使用 // 获取测试文件 resources 路径 String absolutePath = FileUtil.getAbsolutePath("application-unit-test.yaml"); // 系统不一样生成的文件也有差异,那就各自生成各自的 From 34bdf00d66219989d588af8fd5830aa64d2b7b46 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 20 Jan 2024 00:45:34 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E2=9C=A8=20=E5=A2=9E=E5=8A=A0=20jakartaPac?= =?UTF-8?q?kage=20=E6=A0=87=E8=AF=86=EF=BC=8C=E7=BB=9F=E4=B8=80=20Spring?= =?UTF-8?q?=20Boot=202.X=20=E5=92=8C=203.X=20=E4=BB=A3=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=9A=84=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/infra/service/codegen/inner/CodegenEngine.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java index d70452e22..34ba50b97 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java @@ -36,11 +36,11 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableTable; import com.google.common.collect.Maps; import com.google.common.collect.Table; -import jakarta.annotation.PostConstruct; -import jakarta.annotation.Resource; import lombok.Setter; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; +import javax.annotation.Resource; import java.util.*; import static cn.hutool.core.map.MapUtil.getStr;