diff --git a/novel-admin/pom.xml b/novel-admin/pom.xml
index 70b1290..5a7bcaf 100644
--- a/novel-admin/pom.xml
+++ b/novel-admin/pom.xml
@@ -200,10 +200,6 @@
org.springframework.boot
spring-boot-starter-cache
-
- net.sf.ehcache
- ehcache
-
diff --git a/novel-admin/src/main/java/com/java2nb/common/config/ShiroConfig.java b/novel-admin/src/main/java/com/java2nb/common/config/ShiroConfig.java
index 20d344d..39cf48f 100644
--- a/novel-admin/src/main/java/com/java2nb/common/config/ShiroConfig.java
+++ b/novel-admin/src/main/java/com/java2nb/common/config/ShiroConfig.java
@@ -5,11 +5,8 @@ import com.java2nb.common.redis.shiro.RedisCacheManager;
import com.java2nb.common.redis.shiro.RedisManager;
import com.java2nb.common.redis.shiro.RedisSessionDAO;
import com.java2nb.system.shiro.UserRealm;
-import net.sf.ehcache.CacheManager;
-import org.apache.shiro.cache.ehcache.EhCacheManager;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.session.SessionListener;
-import org.apache.shiro.session.mgt.eis.MemorySessionDAO;
import org.apache.shiro.session.mgt.eis.SessionDAO;
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
@@ -29,6 +26,7 @@ import java.util.LinkedHashMap;
*/
@Configuration
public class ShiroConfig {
+
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.password}")
@@ -38,9 +36,6 @@ public class ShiroConfig {
@Value("${spring.redis.timeout}")
private int timeout;
- @Value("${spring.cache.type}")
- private String cacheType ;
-
@Value("${server.session-timeout}")
private int tomcatTimeout;
@@ -67,8 +62,8 @@ public class ShiroConfig {
shiroFilterFactoryBean.setSuccessUrl("/index");
shiroFilterFactoryBean.setUnauthorizedUrl("/403");
LinkedHashMap filterChainDefinitionMap = new LinkedHashMap<>();
- filterChainDefinitionMap.put("/login","anon");
- filterChainDefinitionMap.put("/getVerify","anon");
+ filterChainDefinitionMap.put("/login", "anon");
+ filterChainDefinitionMap.put("/getVerify", "anon");
filterChainDefinitionMap.put("/css/**", "anon");
filterChainDefinitionMap.put("/js/**", "anon");
filterChainDefinitionMap.put("/fonts/**", "anon");
@@ -92,11 +87,7 @@ public class ShiroConfig {
//设置realm.
securityManager.setRealm(userRealm());
// 自定义缓存实现 使用redis
- if (Constant.CACHE_TYPE_REDIS.equals(cacheType)) {
- securityManager.setCacheManager(rediscacheManager());
- } else {
- securityManager.setCacheManager(ehCacheManager());
- }
+ securityManager.setCacheManager(rediscacheManager());
securityManager.setSessionManager(sessionManager());
return securityManager;
}
@@ -108,8 +99,7 @@ public class ShiroConfig {
}
/**
- * 开启shiro aop注解支持.
- * 使用代理方式;所以需要开启代码支持;
+ * 开启shiro aop注解支持. 使用代理方式;所以需要开启代码支持;
*
* @param securityManager
* @return
@@ -138,8 +128,7 @@ public class ShiroConfig {
}
/**
- * cacheManager 缓存 redis实现
- * 使用的是shiro-redis开源插件
+ * cacheManager 缓存 redis实现 使用的是shiro-redis开源插件
*
* @return
*/
@@ -151,8 +140,7 @@ public class ShiroConfig {
/**
- * RedisSessionDAO shiro sessionDao层的实现 通过redis
- * 使用的是shiro-redis开源插件
+ * RedisSessionDAO shiro sessionDao层的实现 通过redis 使用的是shiro-redis开源插件
*/
@Bean
public RedisSessionDAO redisSessionDAO() {
@@ -163,11 +151,7 @@ public class ShiroConfig {
@Bean
public SessionDAO sessionDAO() {
- if (Constant.CACHE_TYPE_REDIS.equals(cacheType)) {
- return redisSessionDAO();
- } else {
- return new MemorySessionDAO();
- }
+ return redisSessionDAO();
}
/**
@@ -184,19 +168,4 @@ public class ShiroConfig {
return sessionManager;
}
- @Bean
- public EhCacheManager ehCacheManager() {
- EhCacheManager em = new EhCacheManager();
- em.setCacheManager(cacheManager());
- return em;
- }
-
- @Bean("cacheManager2")
- CacheManager cacheManager(){
- return CacheManager.create();
- }
-
-
-
-
}
diff --git a/novel-admin/src/main/resources/application-dev.yml b/novel-admin/src/main/resources/application-dev.yml
index c7028e1..647122b 100644
--- a/novel-admin/src/main/resources/application-dev.yml
+++ b/novel-admin/src/main/resources/application-dev.yml
@@ -39,7 +39,7 @@ spring:
redis:
host: 127.0.0.1
port: 6379
- password: test
+ password: test123456
# 连接超时时间(毫秒)
timeout: 10000
jedis:
diff --git a/novel-admin/src/main/resources/application.yml b/novel-admin/src/main/resources/application.yml
index d2e2bf5..7c8e35f 100644
--- a/novel-admin/src/main/resources/application.yml
+++ b/novel-admin/src/main/resources/application.yml
@@ -1,8 +1,8 @@
server:
session-timeout: 18000
-# tomcat:
-# max-threads: 1000
-# min-spare-threads: 30
+ # tomcat:
+ # max-threads: 1000
+ # min-spare-threads: 30
port: 80
# uri-encoding: utf-8
#security:
@@ -15,7 +15,7 @@ spring:
jackson:
time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss
- profiles:
+ profiles:
active: dev
servlet:
multipart:
@@ -24,10 +24,7 @@ spring:
devtools:
restart:
enabled: true
- cache:
- type: ehcache
- ehcache:
- config: classpath:ehcache.xml
+
mybatis:
configuration:
#自动将数据库带下划线的表字段值映射到Java类的驼峰字段上
diff --git a/novel-common/pom.xml b/novel-common/pom.xml
index aa63d57..2a9443d 100644
--- a/novel-common/pom.xml
+++ b/novel-common/pom.xml
@@ -32,12 +32,6 @@
spring-boot-starter-cache
-
-
- net.sf.ehcache
- ehcache
-
-
org.springframework.boot
diff --git a/novel-common/src/main/java/com/java2nb/novel/core/cache/impl/EhCacheServiceImpl.java b/novel-common/src/main/java/com/java2nb/novel/core/cache/impl/EhCacheServiceImpl.java
deleted file mode 100644
index e935bdd..0000000
--- a/novel-common/src/main/java/com/java2nb/novel/core/cache/impl/EhCacheServiceImpl.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package com.java2nb.novel.core.cache.impl;
-
-import com.java2nb.novel.core.cache.CacheService;
-import lombok.RequiredArgsConstructor;
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.Element;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.context.annotation.Primary;
-import org.springframework.stereotype.Service;
-
-/**
- * @author xxy
- */
-@ConditionalOnProperty(prefix = "cache", name = "type", havingValue = "ehcache")
-@RequiredArgsConstructor
-@Service
-public class EhCacheServiceImpl implements CacheService {
-
- private final CacheManager cacheManager;
-
-
- /**
- * 获得一个Cache,没有则创建一个。
- *
- * @return
- */
- private Cache getCache() {
-
- Cache cache = cacheManager.getCache("util_cache");
- return cache;
- }
-
-
- @Override
- public String get(String key) {
- Element element = getCache().get(key);
- return element == null ? null : (String) element.getObjectValue();
- }
-
- @Override
- public void set(String key, String value) {
- Element element = new Element(key, value);
- Cache cache = getCache();
- //不过期
- cache.getCacheConfiguration().setEternal(true);
- cache.put(element);
-
- }
-
- @Override
- public void set(String key, String value, long timeout) {
- Element element = new Element(key, value);
- element.setTimeToLive((int) timeout);
- Cache cache = getCache();
- cache.put(element);
-
- }
-
- @Override
- public void del(String key) {
- getCache().remove(key);
-
-
- }
-
- @Override
- public boolean contains(String key) {
- return getCache().isKeyInCache(key);
- }
-
- @Override
- public void expire(String key, long timeout) {
- Element element = getCache().get(key);
- if (element != null) {
- Object value = element.getValue();
- element = new Element(key, value);
- element.setTimeToLive((int) timeout);
- Cache cache = getCache();
- cache.put(element);
- }
- }
-
-
- /**
- * 根据key获取缓存的Object类型数据
- */
- @Override
- public Object getObject(String key) {
- Element element = getCache().get(key);
- return element == null ? null : element.getObjectValue();
- }
-
-
- /**
- * 设置Object类型的缓存
- */
- @Override
- public void setObject(String key, Object value) {
- Element element = new Element(key, value);
- Cache cache = getCache();
- //不过期
- cache.getCacheConfiguration().setEternal(true);
- cache.put(element);
-
- }
-
-
- /**
- * 设置一个有过期时间的Object类型的缓存,单位秒
- */
- @Override
- public void setObject(String key, Object value, long timeout) {
- Element element = new Element(key, value);
- element.setTimeToLive((int) timeout);
- Cache cache = getCache();
- cache.put(element);
-
- }
-
-
-}
diff --git a/novel-common/src/main/java/com/java2nb/novel/core/cache/impl/RedisServiceImpl.java b/novel-common/src/main/java/com/java2nb/novel/core/cache/impl/RedisServiceImpl.java
index 0498f03..aad1a04 100644
--- a/novel-common/src/main/java/com/java2nb/novel/core/cache/impl/RedisServiceImpl.java
+++ b/novel-common/src/main/java/com/java2nb/novel/core/cache/impl/RedisServiceImpl.java
@@ -2,7 +2,6 @@ package com.java2nb.novel.core.cache.impl;
import com.java2nb.novel.core.cache.CacheService;
import lombok.RequiredArgsConstructor;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
@@ -12,62 +11,61 @@ import java.util.concurrent.TimeUnit;
/**
* @author xxy
*/
-@ConditionalOnProperty(prefix = "cache", name = "type", havingValue = "redis")
@RequiredArgsConstructor
@Service
public class RedisServiceImpl implements CacheService {
- private final StringRedisTemplate stringRedisTemplate;
+ private final StringRedisTemplate stringRedisTemplate;
- private final RedisTemplate