From 7af0ccc612067f2608156cc1bd376fcb8cea8ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Miller=20=28=E9=94=BA=E4=BF=8A=29?= Date: Thu, 14 Jan 2021 11:53:22 +0800 Subject: [PATCH] perf($ORM): migrate Redis library to spring-boot-starter --- auth-center/pom.xml | 10 ------- .../RestTemplateConfiguration.java | 20 ------------- .../application-development-docker.yml | 12 ++------ .../application-development-local.yml | 12 ++------ .../main/resources/application-production.yml | 12 ++------ .../src/main/resources/application-stage.yml | 12 ++------ .../src/main/resources/application-test.yml | 12 ++------ .../src/main/resources/application.yml | 9 ++++++ .../authcenter/mybatis/MyBatisPlusTests.java | 4 +-- .../application-development-docker.yml | 8 +++-- .../application-development-local.yml | 8 +++-- .../main/resources/application-production.yml | 8 +++-- .../src/main/resources/application-stage.yml | 8 +++-- .../src/main/resources/application-test.yml | 8 +++-- .../src/main/resources/application.yml | 9 ++++++ .../application-development-docker.yml | 8 +++-- .../application-development-local.yml | 8 +++-- .../main/resources/application-production.yml | 8 +++-- .../src/main/resources/application-stage.yml | 8 +++-- .../src/main/resources/application-test.yml | 8 +++-- muscle-mis/src/main/resources/application.yml | 9 ++++++ .../application-development-docker.yml | 8 +++-- .../application-development-local.yml | 8 +++-- .../main/resources/application-production.yml | 8 +++-- .../src/main/resources/application-stage.yml | 8 +++-- .../src/main/resources/application-test.yml | 8 +++-- .../src/main/resources/application.yml | 9 ++++++ .../application-development-docker.yml | 9 ++++-- .../application-development-local.yml | 8 +++-- .../main/resources/application-production.yml | 8 +++-- .../src/main/resources/application-stage.yml | 8 +++-- .../src/main/resources/application-test.yml | 8 +++-- .../src/main/resources/application.yml | 9 ++++++ spring-boot-starter/pom.xml | 10 +++++++ .../configuration/MafAutoConfiguration.java | 29 +++++++++++++++++++ .../RedisCachingConfiguration.java | 2 +- .../configuration/RedisConfiguration.java | 2 +- 37 files changed, 219 insertions(+), 124 deletions(-) delete mode 100644 auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/RestTemplateConfiguration.java rename {auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal => spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter}/configuration/RedisCachingConfiguration.java (97%) rename {auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal => spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter}/configuration/RedisConfiguration.java (98%) diff --git a/auth-center/pom.xml b/auth-center/pom.xml index 7ed089d3..7b889b12 100644 --- a/auth-center/pom.xml +++ b/auth-center/pom.xml @@ -78,16 +78,6 @@ spring-boot-starter - - - org.springframework.boot - spring-boot-starter-data-redis - - - redis.clients - jedis - - org.springframework.integration spring-integration-sftp diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/RestTemplateConfiguration.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/RestTemplateConfiguration.java deleted file mode 100644 index 16a317a5..00000000 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/RestTemplateConfiguration.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.jmsoftware.maf.authcenter.universal.configuration; - -import org.springframework.cloud.client.loadbalancer.LoadBalanced; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.client.RestTemplate; - -/** - * Description: RestTemplateConfiguration, change description here. - * - * @author 钟俊(zhongjun), email: zhongjun@toguide.cn, date: 12/25/2020 5:42 PM - **/ -@Configuration -public class RestTemplateConfiguration { - @Bean - @LoadBalanced - public RestTemplate restTemplate() { - return new RestTemplate(); - } -} diff --git a/auth-center/src/main/resources/application-development-docker.yml b/auth-center/src/main/resources/application-development-docker.yml index d4d45da2..0c9eb84e 100644 --- a/auth-center/src/main/resources/application-development-docker.yml +++ b/auth-center/src/main/resources/application-development-docker.yml @@ -6,24 +6,16 @@ eureka: spring: zipkin: base-url: http://maf.open-zipkin.dev:9411 + devtools: + add-properties: true datasource: url: jdbc:mysql://maf.mysql.dev:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql redis: - database: 0 host: maf.redis.dev port: 6379 password: 123456 - timeout: 10000ms - lettuce: - pool: - max-active: 20 - max-idle: 10 - max-wait: -1ms - min-idle: 0 - devtools: - add-properties: true sftp: client: diff --git a/auth-center/src/main/resources/application-development-local.yml b/auth-center/src/main/resources/application-development-local.yml index 8dea6881..dcb955cf 100644 --- a/auth-center/src/main/resources/application-development-local.yml +++ b/auth-center/src/main/resources/application-development-local.yml @@ -6,24 +6,16 @@ eureka: spring: zipkin: base-url: http://localhost:9411 + devtools: + add-properties: true datasource: url: jdbc:mysql://localhost:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql redis: - database: 0 host: localhost port: 6379 password: 123456 - timeout: 10000ms - lettuce: - pool: - max-active: 20 - max-idle: 10 - max-wait: -1ms - min-idle: 0 - devtools: - add-properties: true logging: # Configure logging level for SFTP/JSCH diff --git a/auth-center/src/main/resources/application-production.yml b/auth-center/src/main/resources/application-production.yml index 414c84e0..8a48643f 100644 --- a/auth-center/src/main/resources/application-production.yml +++ b/auth-center/src/main/resources/application-production.yml @@ -6,24 +6,16 @@ eureka: spring: zipkin: base-url: http://maf.open-zipkin.production:9411 + devtools: + add-properties: false datasource: url: jdbc:mysql://maf.mysql.production:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql redis: - database: 0 host: maf.redis.production port: 6379 password: 123456 - timeout: 10000ms - lettuce: - pool: - max-active: 20 - max-idle: 10 - max-wait: -1ms - min-idle: 0 - devtools: - add-properties: false sftp: client: diff --git a/auth-center/src/main/resources/application-stage.yml b/auth-center/src/main/resources/application-stage.yml index 2fcd35a6..815f52f4 100644 --- a/auth-center/src/main/resources/application-stage.yml +++ b/auth-center/src/main/resources/application-stage.yml @@ -6,24 +6,16 @@ eureka: spring: zipkin: base-url: http://maf.open-zipkin.stage:9411 + devtools: + add-properties: false datasource: url: jdbc:mysql://maf.mysql.stage:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql redis: - database: 0 host: maf.redis.stage port: 6379 password: 123456 - timeout: 10000ms - lettuce: - pool: - max-active: 20 - max-idle: 10 - max-wait: -1ms - min-idle: 0 - devtools: - add-properties: false sftp: client: diff --git a/auth-center/src/main/resources/application-test.yml b/auth-center/src/main/resources/application-test.yml index 9dffacde..abbbda15 100644 --- a/auth-center/src/main/resources/application-test.yml +++ b/auth-center/src/main/resources/application-test.yml @@ -6,24 +6,16 @@ eureka: spring: zipkin: base-url: http://maf.open-zipkin.test:9411 + devtools: + add-properties: false datasource: url: jdbc:mysql://maf.mysql.test:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql redis: - database: 0 host: maf.redis.test port: 6379 password: 123456 - timeout: 10000ms - lettuce: - pool: - max-active: 20 - max-idle: 10 - max-wait: -1ms - min-idle: 0 - devtools: - add-properties: false sftp: client: diff --git a/auth-center/src/main/resources/application.yml b/auth-center/src/main/resources/application.yml index 256a87c1..9110a68a 100644 --- a/auth-center/src/main/resources/application.yml +++ b/auth-center/src/main/resources/application.yml @@ -32,6 +32,15 @@ spring: name: muscle_and_fitness driver-class-name: com.mysql.cj.jdbc.Driver type: com.alibaba.druid.pool.DruidDataSource + redis: + database: 0 + timeout: 10000ms + lettuce: + pool: + max-active: 20 + max-idle: 10 + max-wait: -1ms + min-idle: 0 eureka: instance: diff --git a/auth-center/src/test/java/com/jmsoftware/maf/authcenter/mybatis/MyBatisPlusTests.java b/auth-center/src/test/java/com/jmsoftware/maf/authcenter/mybatis/MyBatisPlusTests.java index 8248fd2b..3f458cb4 100644 --- a/auth-center/src/test/java/com/jmsoftware/maf/authcenter/mybatis/MyBatisPlusTests.java +++ b/auth-center/src/test/java/com/jmsoftware/maf/authcenter/mybatis/MyBatisPlusTests.java @@ -66,7 +66,7 @@ void logicDeleteTest() { val rolePersistence2 = roleMapper.selectByName(rolePersistence.getName()); log.info("Deleted role: {}", rolePersistence2); Assertions.assertEquals(rolePersistence2.getDeleted(), DeleteFlag.DELETED.getValue()); - roleMapper.selectByName("role-for-mybatis-plus-tests"); - log.warn("Role not found! {}", lambdaQuery.getEntity()); + final var deletedRolePersistence = roleService.getOne(lambdaQuery); + Assertions.assertNull(deletedRolePersistence); } } diff --git a/exercise-mis/src/main/resources/application-development-docker.yml b/exercise-mis/src/main/resources/application-development-docker.yml index df81b24e..95a2f02f 100644 --- a/exercise-mis/src/main/resources/application-development-docker.yml +++ b/exercise-mis/src/main/resources/application-development-docker.yml @@ -6,12 +6,16 @@ eureka: spring: zipkin: base-url: http://maf.open-zipkin.dev:9411 + devtools: + add-properties: true datasource: url: jdbc:mysql://maf.mysql.dev:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: true + redis: + host: maf.redis.dev + port: 6379 + password: 123456 maf: configuration: diff --git a/exercise-mis/src/main/resources/application-development-local.yml b/exercise-mis/src/main/resources/application-development-local.yml index 181aeaff..d476f591 100644 --- a/exercise-mis/src/main/resources/application-development-local.yml +++ b/exercise-mis/src/main/resources/application-development-local.yml @@ -6,12 +6,16 @@ eureka: spring: zipkin: base-url: http://localhost:9411 + devtools: + add-properties: true datasource: url: jdbc:mysql://localhost:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: true + redis: + host: localhost + port: 6379 + password: 123456 maf: configuration: diff --git a/exercise-mis/src/main/resources/application-production.yml b/exercise-mis/src/main/resources/application-production.yml index 89171f25..f0f513d5 100644 --- a/exercise-mis/src/main/resources/application-production.yml +++ b/exercise-mis/src/main/resources/application-production.yml @@ -6,12 +6,16 @@ eureka: spring: zipkin: base-url: http://maf.open-zipkin.production:9411 + devtools: + add-properties: false datasource: url: jdbc:mysql://maf.mysql.production:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: false + redis: + host: maf.redis.production + port: 6379 + password: 123456 maf: configuration: diff --git a/exercise-mis/src/main/resources/application-stage.yml b/exercise-mis/src/main/resources/application-stage.yml index dca7b8ba..b1f65326 100644 --- a/exercise-mis/src/main/resources/application-stage.yml +++ b/exercise-mis/src/main/resources/application-stage.yml @@ -6,12 +6,16 @@ eureka: spring: zipkin: base-url: http://maf.open-zipkin.stage:9411 + devtools: + add-properties: false datasource: url: jdbc:mysql://maf.mysql.stage:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: false + redis: + host: maf.redis.stage + port: 6379 + password: 123456 maf: configuration: diff --git a/exercise-mis/src/main/resources/application-test.yml b/exercise-mis/src/main/resources/application-test.yml index f49425c0..d1145bc4 100644 --- a/exercise-mis/src/main/resources/application-test.yml +++ b/exercise-mis/src/main/resources/application-test.yml @@ -6,12 +6,16 @@ eureka: spring: zipkin: base-url: http://maf.open-zipkin.test:9411 + devtools: + add-properties: false datasource: url: jdbc:mysql://maf.mysql.test:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: false + redis: + host: maf.redis.test + port: 6379 + password: 123456 maf: configuration: diff --git a/exercise-mis/src/main/resources/application.yml b/exercise-mis/src/main/resources/application.yml index dfba1574..d95da3fd 100644 --- a/exercise-mis/src/main/resources/application.yml +++ b/exercise-mis/src/main/resources/application.yml @@ -32,6 +32,15 @@ spring: name: muscle_and_fitness driver-class-name: com.mysql.cj.jdbc.Driver type: com.alibaba.druid.pool.DruidDataSource + redis: + database: 0 + timeout: 10000ms + lettuce: + pool: + max-active: 20 + max-idle: 10 + max-wait: -1ms + min-idle: 0 eureka: instance: diff --git a/muscle-mis/src/main/resources/application-development-docker.yml b/muscle-mis/src/main/resources/application-development-docker.yml index df81b24e..95a2f02f 100644 --- a/muscle-mis/src/main/resources/application-development-docker.yml +++ b/muscle-mis/src/main/resources/application-development-docker.yml @@ -6,12 +6,16 @@ eureka: spring: zipkin: base-url: http://maf.open-zipkin.dev:9411 + devtools: + add-properties: true datasource: url: jdbc:mysql://maf.mysql.dev:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: true + redis: + host: maf.redis.dev + port: 6379 + password: 123456 maf: configuration: diff --git a/muscle-mis/src/main/resources/application-development-local.yml b/muscle-mis/src/main/resources/application-development-local.yml index 581c2d65..e7b2fb48 100644 --- a/muscle-mis/src/main/resources/application-development-local.yml +++ b/muscle-mis/src/main/resources/application-development-local.yml @@ -6,12 +6,16 @@ eureka: spring: zipkin: base-url: http://localhost:9411 + devtools: + add-properties: true datasource: url: jdbc:mysql://localhost:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: true + redis: + host: localhost + port: 6379 + password: 123456 logging: level: diff --git a/muscle-mis/src/main/resources/application-production.yml b/muscle-mis/src/main/resources/application-production.yml index 89171f25..f0f513d5 100644 --- a/muscle-mis/src/main/resources/application-production.yml +++ b/muscle-mis/src/main/resources/application-production.yml @@ -6,12 +6,16 @@ eureka: spring: zipkin: base-url: http://maf.open-zipkin.production:9411 + devtools: + add-properties: false datasource: url: jdbc:mysql://maf.mysql.production:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: false + redis: + host: maf.redis.production + port: 6379 + password: 123456 maf: configuration: diff --git a/muscle-mis/src/main/resources/application-stage.yml b/muscle-mis/src/main/resources/application-stage.yml index dca7b8ba..b1f65326 100644 --- a/muscle-mis/src/main/resources/application-stage.yml +++ b/muscle-mis/src/main/resources/application-stage.yml @@ -6,12 +6,16 @@ eureka: spring: zipkin: base-url: http://maf.open-zipkin.stage:9411 + devtools: + add-properties: false datasource: url: jdbc:mysql://maf.mysql.stage:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: false + redis: + host: maf.redis.stage + port: 6379 + password: 123456 maf: configuration: diff --git a/muscle-mis/src/main/resources/application-test.yml b/muscle-mis/src/main/resources/application-test.yml index f49425c0..d1145bc4 100644 --- a/muscle-mis/src/main/resources/application-test.yml +++ b/muscle-mis/src/main/resources/application-test.yml @@ -6,12 +6,16 @@ eureka: spring: zipkin: base-url: http://maf.open-zipkin.test:9411 + devtools: + add-properties: false datasource: url: jdbc:mysql://maf.mysql.test:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: false + redis: + host: maf.redis.test + port: 6379 + password: 123456 maf: configuration: diff --git a/muscle-mis/src/main/resources/application.yml b/muscle-mis/src/main/resources/application.yml index 1d549e6f..06b2e7eb 100644 --- a/muscle-mis/src/main/resources/application.yml +++ b/muscle-mis/src/main/resources/application.yml @@ -20,6 +20,15 @@ spring: name: muscle_and_fitness driver-class-name: com.mysql.cj.jdbc.Driver type: com.alibaba.druid.pool.DruidDataSource + redis: + database: 0 + timeout: 10000ms + lettuce: + pool: + max-active: 20 + max-idle: 10 + max-wait: -1ms + min-idle: 0 eureka: instance: diff --git a/service-registry/src/main/resources/application-development-docker.yml b/service-registry/src/main/resources/application-development-docker.yml index 98bf1a91..eb3eafa9 100644 --- a/service-registry/src/main/resources/application-development-docker.yml +++ b/service-registry/src/main/resources/application-development-docker.yml @@ -1,10 +1,14 @@ spring: + devtools: + add-properties: true datasource: url: jdbc:mysql://maf.mysql.dev:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: true + redis: + host: maf.redis.dev + port: 6379 + password: 123456 eureka: client: diff --git a/service-registry/src/main/resources/application-development-local.yml b/service-registry/src/main/resources/application-development-local.yml index 3400a028..f19e1478 100644 --- a/service-registry/src/main/resources/application-development-local.yml +++ b/service-registry/src/main/resources/application-development-local.yml @@ -1,10 +1,14 @@ spring: + devtools: + add-properties: true datasource: url: jdbc:mysql://localhost:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: true + redis: + host: localhost + port: 6379 + password: 123456 eureka: client: diff --git a/service-registry/src/main/resources/application-production.yml b/service-registry/src/main/resources/application-production.yml index fcc87e15..66612260 100644 --- a/service-registry/src/main/resources/application-production.yml +++ b/service-registry/src/main/resources/application-production.yml @@ -1,10 +1,14 @@ spring: + devtools: + add-properties: false datasource: url: jdbc:mysql://maf.mysql.production:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: false + redis: + host: maf.redis.production + port: 6379 + password: 123456 eureka: client: diff --git a/service-registry/src/main/resources/application-stage.yml b/service-registry/src/main/resources/application-stage.yml index cbff4fa8..7806aec9 100644 --- a/service-registry/src/main/resources/application-stage.yml +++ b/service-registry/src/main/resources/application-stage.yml @@ -1,10 +1,14 @@ spring: + devtools: + add-properties: false datasource: url: jdbc:mysql://maf.mysql.stage:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: false + redis: + host: maf.redis.stage + port: 6379 + password: 123456 eureka: client: diff --git a/service-registry/src/main/resources/application-test.yml b/service-registry/src/main/resources/application-test.yml index 8725be62..ba78232b 100644 --- a/service-registry/src/main/resources/application-test.yml +++ b/service-registry/src/main/resources/application-test.yml @@ -1,10 +1,14 @@ spring: + devtools: + add-properties: false datasource: url: jdbc:mysql://maf.mysql.test:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: false + redis: + host: maf.redis.test + port: 6379 + password: 123456 eureka: client: diff --git a/service-registry/src/main/resources/application.yml b/service-registry/src/main/resources/application.yml index 1999ab09..e1f71914 100644 --- a/service-registry/src/main/resources/application.yml +++ b/service-registry/src/main/resources/application.yml @@ -17,6 +17,15 @@ spring: name: muscle_and_fitness driver-class-name: com.mysql.cj.jdbc.Driver type: com.alibaba.druid.pool.DruidDataSource + redis: + database: 0 + timeout: 10000ms + lettuce: + pool: + max-active: 20 + max-idle: 10 + max-wait: -1ms + min-idle: 0 eureka: instance: diff --git a/spring-boot-admin/src/main/resources/application-development-docker.yml b/spring-boot-admin/src/main/resources/application-development-docker.yml index 0dc04609..2fc2f6f0 100644 --- a/spring-boot-admin/src/main/resources/application-development-docker.yml +++ b/spring-boot-admin/src/main/resources/application-development-docker.yml @@ -1,9 +1,14 @@ spring: + devtools: + add-properties: true + datasource: url: jdbc:mysql://maf.mysql.dev:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: true + redis: + host: maf.redis.dev + port: 6379 + password: 123456 eureka: client: diff --git a/spring-boot-admin/src/main/resources/application-development-local.yml b/spring-boot-admin/src/main/resources/application-development-local.yml index cc977f6e..b2a08909 100644 --- a/spring-boot-admin/src/main/resources/application-development-local.yml +++ b/spring-boot-admin/src/main/resources/application-development-local.yml @@ -1,10 +1,14 @@ spring: + devtools: + add-properties: true datasource: url: jdbc:mysql://localhost:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: true + redis: + host: localhost + port: 6379 + password: 123456 eureka: client: diff --git a/spring-boot-admin/src/main/resources/application-production.yml b/spring-boot-admin/src/main/resources/application-production.yml index 47bb4564..33f89d0f 100644 --- a/spring-boot-admin/src/main/resources/application-production.yml +++ b/spring-boot-admin/src/main/resources/application-production.yml @@ -1,10 +1,14 @@ spring: + devtools: + add-properties: false datasource: url: jdbc:mysql://maf.mysql.production:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: false + redis: + host: maf.redis.production + port: 6379 + password: 123456 eureka: client: diff --git a/spring-boot-admin/src/main/resources/application-stage.yml b/spring-boot-admin/src/main/resources/application-stage.yml index 9d44ac30..5d0284c8 100644 --- a/spring-boot-admin/src/main/resources/application-stage.yml +++ b/spring-boot-admin/src/main/resources/application-stage.yml @@ -1,10 +1,14 @@ spring: + devtools: + add-properties: false datasource: url: jdbc:mysql://maf.mysql.stage:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: false + redis: + host: maf.redis.stage + port: 6379 + password: 123456 eureka: client: diff --git a/spring-boot-admin/src/main/resources/application-test.yml b/spring-boot-admin/src/main/resources/application-test.yml index 9867a5ac..cc43603b 100644 --- a/spring-boot-admin/src/main/resources/application-test.yml +++ b/spring-boot-admin/src/main/resources/application-test.yml @@ -1,10 +1,14 @@ spring: + devtools: + add-properties: false datasource: url: jdbc:mysql://maf.mysql.test:3306/muscle_and_fitness?useSSL=true&useUnicode=true username: root password: jm@mysql - devtools: - add-properties: false + redis: + host: maf.redis.test + port: 6379 + password: 123456 eureka: client: diff --git a/spring-boot-admin/src/main/resources/application.yml b/spring-boot-admin/src/main/resources/application.yml index ff457385..82014216 100644 --- a/spring-boot-admin/src/main/resources/application.yml +++ b/spring-boot-admin/src/main/resources/application.yml @@ -17,6 +17,15 @@ spring: name: muscle_and_fitness driver-class-name: com.mysql.cj.jdbc.Driver type: com.alibaba.druid.pool.DruidDataSource + redis: + database: 0 + timeout: 10000ms + lettuce: + pool: + max-active: 20 + max-idle: 10 + max-wait: -1ms + min-idle: 0 eureka: instance: diff --git a/spring-boot-starter/pom.xml b/spring-boot-starter/pom.xml index 5fb33ce9..3d80b30f 100644 --- a/spring-boot-starter/pom.xml +++ b/spring-boot-starter/pom.xml @@ -89,5 +89,15 @@ druid ${druid.version} + + + + org.springframework.boot + spring-boot-starter-data-redis + + + redis.clients + jedis + diff --git a/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/MafAutoConfiguration.java b/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/MafAutoConfiguration.java index 39c1f47d..434b97e4 100644 --- a/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/MafAutoConfiguration.java +++ b/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/MafAutoConfiguration.java @@ -1,5 +1,6 @@ package com.jmsoftware.maf.springbootstarter.configuration; +import com.fasterxml.jackson.databind.ObjectMapper; import com.jmsoftware.maf.springbootstarter.aspect.ExceptionControllerAdvice; import com.jmsoftware.maf.springbootstarter.aspect.WebRequestLogAspect; import com.jmsoftware.maf.springbootstarter.controller.CommonController; @@ -23,9 +24,12 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.web.servlet.error.ErrorAttributes; import org.springframework.boot.web.servlet.error.ErrorController; +import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.web.client.RestTemplate; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; @@ -180,4 +184,29 @@ public MyBatisPlusConfiguration myBatisPlusConfiguration() { log.warn("Initial bean: {}", MyBatisPlusConfiguration.class.getSimpleName()); return new MyBatisPlusConfiguration(); } + +// @Bean +// RedisConnectionFactory redisConnectionFactory() { +// log.warn("Initial bean: {}", LettuceConnectionConfiguration.class.getSimpleName()); +// return new LettuceConnectionConfiguration(); +// } + + @Bean + public RedisCachingConfiguration redisCachingConfiguration(RedisConnectionFactory redisConnectionFactory) { + log.warn("Initial bean: {}", RedisCachingConfiguration.class.getSimpleName()); + return new RedisCachingConfiguration(redisConnectionFactory); + } + + @Bean + public RedisConfiguration redisConfiguration(ObjectMapper objectMapper) { + log.warn("Initial bean: {}", RedisConfiguration.class.getSimpleName()); + return new RedisConfiguration(objectMapper); + } + + @Bean + @LoadBalanced + public RestTemplate restTemplate() { + log.warn("Initial bean: {}", RestTemplate.class.getSimpleName()); + return new RestTemplate(); + } } diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/RedisCachingConfiguration.java b/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/RedisCachingConfiguration.java similarity index 97% rename from auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/RedisCachingConfiguration.java rename to spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/RedisCachingConfiguration.java index d61670c6..2e32ea7c 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/RedisCachingConfiguration.java +++ b/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/RedisCachingConfiguration.java @@ -1,4 +1,4 @@ -package com.jmsoftware.maf.authcenter.universal.configuration; +package com.jmsoftware.maf.springbootstarter.configuration; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/RedisConfiguration.java b/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/RedisConfiguration.java similarity index 98% rename from auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/RedisConfiguration.java rename to spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/RedisConfiguration.java index cc91f9a5..9a74623e 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/RedisConfiguration.java +++ b/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/RedisConfiguration.java @@ -1,4 +1,4 @@ -package com.jmsoftware.maf.authcenter.universal.configuration; +package com.jmsoftware.maf.springbootstarter.configuration; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.RequiredArgsConstructor;