From 3f3c0ef209a2ccb94fa96be430666253b51d490e Mon Sep 17 00:00:00 2001 From: "wangiegie@gmail.com" Date: Sun, 29 Oct 2017 20:30:10 +0800 Subject: [PATCH] =?UTF-8?q?fixed=EF=BC=9Aredis=E5=BA=8F=E5=88=97=E5=8C=96?= =?UTF-8?q?=E5=92=8Ccache=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/pig/auth/config/RedisCacheConfig.java | 5 ++++- .../src/main/resources/mapper/SysUserMapper.xml | 1 + .../github/pig/common/util/MybatisPlusGenerator.java | 12 ++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pig-auth-service/src/main/java/com/github/pig/auth/config/RedisCacheConfig.java b/pig-auth-service/src/main/java/com/github/pig/auth/config/RedisCacheConfig.java index 7cd5d73c..d4e0649f 100644 --- a/pig-auth-service/src/main/java/com/github/pig/auth/config/RedisCacheConfig.java +++ b/pig-auth-service/src/main/java/com/github/pig/auth/config/RedisCacheConfig.java @@ -1,6 +1,7 @@ package com.github.pig.auth.config; import com.github.pig.common.constant.CommonConstant; +import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.EnableCaching; @@ -20,11 +21,13 @@ import org.springframework.data.redis.serializer.StringRedisSerializer; @Configuration @EnableCaching public class RedisCacheConfig extends CachingConfigurerSupport { + @Value("${redis.cache.expiration}") + private Long expiration; @SuppressWarnings("rawtypes") @Bean public CacheManager cacheManager(RedisTemplate redisTemplate) { RedisCacheManager rcm = new RedisCacheManager(redisTemplate); - rcm.setDefaultExpiration(3600);//秒 + rcm.setDefaultExpiration(expiration); return rcm; } diff --git a/pig-auth-service/src/main/resources/mapper/SysUserMapper.xml b/pig-auth-service/src/main/resources/mapper/SysUserMapper.xml index 90d4f7ea..19d30018 100644 --- a/pig-auth-service/src/main/resources/mapper/SysUserMapper.xml +++ b/pig-auth-service/src/main/resources/mapper/SysUserMapper.xml @@ -1,6 +1,7 @@ + diff --git a/pig-common/src/main/java/com/github/pig/common/util/MybatisPlusGenerator.java b/pig-common/src/main/java/com/github/pig/common/util/MybatisPlusGenerator.java index e95b7d2d..959621e5 100644 --- a/pig-common/src/main/java/com/github/pig/common/util/MybatisPlusGenerator.java +++ b/pig-common/src/main/java/com/github/pig/common/util/MybatisPlusGenerator.java @@ -21,9 +21,12 @@ public class MybatisPlusGenerator { gc.setOutputDir("D://data"); gc.setFileOverride(true); gc.setActiveRecord(true); - gc.setEnableCache(false);// XML 二级缓存 - gc.setBaseResultMap(true);// XML ResultMap - gc.setBaseColumnList(false);// XML columList + // XML 二级缓存 + gc.setEnableCache(true); + // XML ResultMap + gc.setBaseResultMap(true); + // XML columList + gc.setBaseColumnList(false); gc.setAuthor("lengleng"); mpg.setGlobalConfig(gc); @@ -40,7 +43,8 @@ public class MybatisPlusGenerator { StrategyConfig strategy = new StrategyConfig(); // strategy.setCapitalMode(true);// 全局大写命名 ORACLE 注意 //strategy.setTablePrefix(new String[]{"tlog_", "tsys_"});// 此处可以修改为您的表前缀 - strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略 + // 表名生成策略 + strategy.setNaming(NamingStrategy.underline_to_camel); mpg.setStrategy(strategy); // 包配置