Commit 50371b367680de18115b0ec2e20a7144bb326176
1 parent
62c4838b
1. 禁用 member 模块
2. 减少 mybatis 日志打印 3. 降低 local 环境的初始连接 目的:提升项目的启动速度
Showing
5 changed files
with
16 additions
and
51 deletions
yudao-framework/yudao-spring-boot-starter-biz-tenant/src/test/java/cn/iocoder/yudao/framework/tenant/core/job/TenantJobTest.java deleted
| 1 | -package cn.iocoder.yudao.framework.tenant.core.job; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService; | ||
| 4 | -import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; | ||
| 5 | -import com.google.common.collect.Lists; | ||
| 6 | -import org.junit.jupiter.api.Test; | ||
| 7 | -import org.mockito.Mock; | ||
| 8 | -import org.mockito.Mockito; | ||
| 9 | - | ||
| 10 | -import java.util.List; | ||
| 11 | - | ||
| 12 | -import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| 13 | - | ||
| 14 | -/** | ||
| 15 | - * 验证 job 租户逻辑 | ||
| 16 | - * {@link TenantJobHandlerDecorator} | ||
| 17 | - * | ||
| 18 | - * @author gaibu | ||
| 19 | - */ | ||
| 20 | -public class TenantJobTest extends BaseMockitoUnitTest { | ||
| 21 | - | ||
| 22 | - @Mock | ||
| 23 | - TenantFrameworkService tenantFrameworkService; | ||
| 24 | - | ||
| 25 | - @Test | ||
| 26 | - public void test() throws Exception { | ||
| 27 | - // 准备测试租户 id | ||
| 28 | - List<Long> tenantIds = Lists.newArrayList(1L, 2L, 3L); | ||
| 29 | - // mock 数据 | ||
| 30 | - Mockito.doReturn(tenantIds).when(tenantFrameworkService).getTenantIds(); | ||
| 31 | - // 准备测试任务 | ||
| 32 | - TestJob testJob = new TestJob(); | ||
| 33 | - // 创建任务装饰器 | ||
| 34 | - TenantJobHandlerDecorator tenantJobHandlerDecorator = new TenantJobHandlerDecorator(tenantFrameworkService, testJob); | ||
| 35 | - | ||
| 36 | - // 执行任务 | ||
| 37 | - tenantJobHandlerDecorator.execute(null); | ||
| 38 | - | ||
| 39 | - // 断言返回值 | ||
| 40 | - assertEquals(testJob.getTenantIds(), tenantIds); | ||
| 41 | - } | ||
| 42 | -} |
yudao-framework/yudao-spring-boot-starter-biz-tenant/src/test/java/cn/iocoder/yudao/framework/tenant/core/job/TestJob.java
| @@ -9,12 +9,12 @@ import java.util.List; | @@ -9,12 +9,12 @@ import java.util.List; | ||
| 9 | import java.util.concurrent.CopyOnWriteArrayList; | 9 | import java.util.concurrent.CopyOnWriteArrayList; |
| 10 | 10 | ||
| 11 | @Component | 11 | @Component |
| 12 | -@TenantJob // 标记多租户 | ||
| 13 | public class TestJob implements JobHandler { | 12 | public class TestJob implements JobHandler { |
| 14 | 13 | ||
| 15 | private final List<Long> tenantIds = new CopyOnWriteArrayList<>(); | 14 | private final List<Long> tenantIds = new CopyOnWriteArrayList<>(); |
| 16 | 15 | ||
| 17 | @Override | 16 | @Override |
| 17 | + @TenantJob // 标记多租户 | ||
| 18 | public String execute(String param) throws Exception { | 18 | public String execute(String param) throws Exception { |
| 19 | tenantIds.add(TenantContextHolder.getTenantId()); | 19 | tenantIds.add(TenantContextHolder.getTenantId()); |
| 20 | return "success"; | 20 | return "success"; |
| @@ -24,4 +24,5 @@ public class TestJob implements JobHandler { | @@ -24,4 +24,5 @@ public class TestJob implements JobHandler { | ||
| 24 | CollUtil.sort(tenantIds, Long::compareTo); | 24 | CollUtil.sort(tenantIds, Long::compareTo); |
| 25 | return tenantIds; | 25 | return tenantIds; |
| 26 | } | 26 | } |
| 27 | + | ||
| 27 | } | 28 | } |
yudao-server/pom.xml
| @@ -23,11 +23,6 @@ | @@ -23,11 +23,6 @@ | ||
| 23 | <dependencies> | 23 | <dependencies> |
| 24 | <dependency> | 24 | <dependency> |
| 25 | <groupId>cn.iocoder.boot</groupId> | 25 | <groupId>cn.iocoder.boot</groupId> |
| 26 | - <artifactId>yudao-module-member-biz</artifactId> | ||
| 27 | - <version>${revision}</version> | ||
| 28 | - </dependency> | ||
| 29 | - <dependency> | ||
| 30 | - <groupId>cn.iocoder.boot</groupId> | ||
| 31 | <artifactId>yudao-module-system-biz</artifactId> | 26 | <artifactId>yudao-module-system-biz</artifactId> |
| 32 | <version>${revision}</version> | 27 | <version>${revision}</version> |
| 33 | </dependency> | 28 | </dependency> |
| @@ -41,6 +36,13 @@ | @@ -41,6 +36,13 @@ | ||
| 41 | <artifactId>yudao-spring-boot-starter-biz-error-code</artifactId> | 36 | <artifactId>yudao-spring-boot-starter-biz-error-code</artifactId> |
| 42 | </dependency> | 37 | </dependency> |
| 43 | 38 | ||
| 39 | + <!-- 会员中心。默认注释,保证编译速度 --> | ||
| 40 | +<!-- <dependency>--> | ||
| 41 | +<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 42 | +<!-- <artifactId>yudao-module-member-biz</artifactId>--> | ||
| 43 | +<!-- <version>${revision}</version>--> | ||
| 44 | +<!-- </dependency>--> | ||
| 45 | + | ||
| 44 | <!-- 数据报表。默认注释,保证编译速度 --> | 46 | <!-- 数据报表。默认注释,保证编译速度 --> |
| 45 | <!-- <dependency>--> | 47 | <!-- <dependency>--> |
| 46 | <!-- <groupId>cn.iocoder.boot</groupId>--> | 48 | <!-- <groupId>cn.iocoder.boot</groupId>--> |
yudao-server/src/main/resources/application-local.yaml
| @@ -34,8 +34,8 @@ spring: | @@ -34,8 +34,8 @@ spring: | ||
| 34 | multi-statement-allow: true | 34 | multi-statement-allow: true |
| 35 | dynamic: # 多数据源配置 | 35 | dynamic: # 多数据源配置 |
| 36 | druid: # Druid 【连接池】相关的全局配置 | 36 | druid: # Druid 【连接池】相关的全局配置 |
| 37 | - initial-size: 5 # 初始连接数 | ||
| 38 | - min-idle: 10 # 最小连接池数量 | 37 | + initial-size: 1 # 初始连接数 |
| 38 | + min-idle: 1 # 最小连接池数量 | ||
| 39 | max-active: 20 # 最大连接池数量 | 39 | max-active: 20 # 最大连接池数量 |
| 40 | max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 | 40 | max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 |
| 41 | time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 | 41 | time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 |
| @@ -60,6 +60,7 @@ spring: | @@ -60,6 +60,7 @@ spring: | ||
| 60 | # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W | 60 | # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W |
| 61 | slave: # 模拟从库,可根据自己需要修改 | 61 | slave: # 模拟从库,可根据自己需要修改 |
| 62 | name: ruoyi-vue-pro | 62 | name: ruoyi-vue-pro |
| 63 | + lazy: true # 开启懒加载,保证启动速度 | ||
| 63 | url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 | 64 | url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 |
| 64 | # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 | 65 | # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 |
| 65 | # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例 | 66 | # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例 |
yudao-server/src/main/resources/application.yaml
| @@ -73,17 +73,20 @@ mybatis-plus: | @@ -73,17 +73,20 @@ mybatis-plus: | ||
| 73 | # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 | 73 | # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 |
| 74 | logic-delete-value: 1 # 逻辑已删除值(默认为 1) | 74 | logic-delete-value: 1 # 逻辑已删除值(默认为 1) |
| 75 | logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) | 75 | logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) |
| 76 | + banner: false # 关闭控制台的 Banner 打印 | ||
| 76 | type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject | 77 | type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject |
| 77 | encryptor: | 78 | encryptor: |
| 78 | password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 | 79 | password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 |
| 79 | 80 | ||
| 81 | +mybatis-plus-join: | ||
| 82 | + banner: false # 关闭控制台的 Banner 打印 | ||
| 83 | + | ||
| 80 | # Spring Data Redis 配置 | 84 | # Spring Data Redis 配置 |
| 81 | spring: | 85 | spring: |
| 82 | data: | 86 | data: |
| 83 | redis: | 87 | redis: |
| 84 | repositories: | 88 | repositories: |
| 85 | enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 | 89 | enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 |
| 86 | - | ||
| 87 | --- #################### 验证码相关配置 #################### | 90 | --- #################### 验证码相关配置 #################### |
| 88 | 91 | ||
| 89 | aj: | 92 | aj: |