mirror of https://github.com/jeecgboot/jeecg-boot
Merge pull request #5605 from EightMonth/master
修复 #5556 sentinel配置文件修改账号密码,logging.level.pattern 等配置无效! #5556 shiro集成 redis 不支持 sentinel 方式部署的redis集群 #5569pull/5673/merge
commit
a85499119d
|
@ -19,6 +19,8 @@ services:
|
|||
--default-authentication-plugin=caching_sha2_password
|
||||
ports:
|
||||
- 3306:3306
|
||||
networks:
|
||||
- jeecg-boot
|
||||
|
||||
jeecg-boot-redis:
|
||||
image: redis:5.0
|
||||
|
@ -27,6 +29,8 @@ services:
|
|||
restart: always
|
||||
hostname: jeecg-boot-redis
|
||||
container_name: jeecg-boot-redis
|
||||
networks:
|
||||
- jeecg-boot
|
||||
|
||||
jeecg-boot-system:
|
||||
build:
|
||||
|
@ -40,3 +44,9 @@ services:
|
|||
hostname: jeecg-boot-system
|
||||
ports:
|
||||
- 8080:8080
|
||||
networks:
|
||||
- jeecg-boot
|
||||
|
||||
networks:
|
||||
jeecg-boot:
|
||||
name: jeecg_boot
|
||||
|
|
|
@ -9,10 +9,7 @@ import org.apache.shiro.spring.LifecycleBeanPostProcessor;
|
|||
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
|
||||
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
|
||||
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
|
||||
import org.crazycake.shiro.IRedisManager;
|
||||
import org.crazycake.shiro.RedisCacheManager;
|
||||
import org.crazycake.shiro.RedisClusterManager;
|
||||
import org.crazycake.shiro.RedisManager;
|
||||
import org.crazycake.shiro.*;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.config.JeecgBaseConfig;
|
||||
|
@ -20,11 +17,13 @@ import org.jeecg.config.shiro.filters.CustomShiroFilterFactoryBean;
|
|||
import org.jeecg.config.shiro.filters.JwtFilter;
|
||||
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import redis.clients.jedis.HostAndPort;
|
||||
import redis.clients.jedis.JedisCluster;
|
||||
|
@ -32,6 +31,7 @@ import redis.clients.jedis.JedisCluster;
|
|||
import javax.annotation.Resource;
|
||||
import javax.servlet.Filter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author: Scott
|
||||
|
@ -49,6 +49,8 @@ public class ShiroConfig {
|
|||
private Environment env;
|
||||
@Resource
|
||||
private JeecgBaseConfig jeecgBaseConfig;
|
||||
@Autowired(required = false)
|
||||
private RedisProperties redisProperties;
|
||||
|
||||
/**
|
||||
* Filter Chain定义说明
|
||||
|
@ -251,6 +253,19 @@ public class ShiroConfig {
|
|||
public IRedisManager redisManager() {
|
||||
log.info("===============(2)创建RedisManager,连接Redis..");
|
||||
IRedisManager manager;
|
||||
|
||||
// sentinel cluster redis
|
||||
if (Objects.nonNull(redisProperties)
|
||||
&& Objects.nonNull(redisProperties.getSentinel())
|
||||
&& !CollectionUtils.isEmpty(redisProperties.getSentinel().getNodes())) {
|
||||
RedisSentinelManager sentinelManager = new RedisSentinelManager();
|
||||
sentinelManager.setMasterName(redisProperties.getSentinel().getMaster());
|
||||
sentinelManager.setHost(String.join(",", redisProperties.getSentinel().getNodes()));
|
||||
sentinelManager.setPassword(redisProperties.getSentinel().getPassword());
|
||||
sentinelManager.setDatabase(redisProperties.getDatabase());
|
||||
|
||||
return sentinelManager;
|
||||
}
|
||||
// redis 单机支持,在集群为空,或者集群无机器时候使用 add by jzyadmin@163.com
|
||||
if (lettuceConnectionFactory.getClusterConfiguration() == null || lettuceConnectionFactory.getClusterConfiguration().getClusterNodes().isEmpty()) {
|
||||
RedisManager redisManager = new RedisManager();
|
||||
|
|
|
@ -36,6 +36,9 @@ public class JeecgSentinelApplication {
|
|||
triggerSentinelInit();
|
||||
ConfigurableApplicationContext application = SpringApplication.run(JeecgSentinelApplication.class, args);
|
||||
Environment env = application.getEnvironment();
|
||||
// 目前jeecg-sentinel 1.8.3 版本存在alibaba-sentinel 1.8.3版本 启动nacos数据源导致配置不生效的问题,以下为临时处理办法
|
||||
System.getProperties().setProperty("sentinel.dashboard.auth.username", env.getProperty("sentinel.dashboard.auth.username"));
|
||||
System.getProperties().setProperty("sentinel.dashboard.auth.password", env.getProperty("sentinel.dashboard.auth.password"));
|
||||
String port = env.getProperty("server.port");
|
||||
log.info("\n----------------------------------------------------------\n\t" +
|
||||
"Application SentinelDashboard is running! Access URLs:\n\t" +
|
||||
|
|
|
@ -18,8 +18,6 @@ auth:
|
|||
filter:
|
||||
exclude-url-suffixes: htm,html,js,css,map,ico,ttf,woff,png
|
||||
exclude-urls: /,/auth/login,/auth/logout,/registry/machine,/version
|
||||
password: sentinel
|
||||
username: sentinel
|
||||
logging:
|
||||
level:
|
||||
org:
|
||||
|
@ -35,3 +33,6 @@ nacos:
|
|||
sentinel:
|
||||
dashboard:
|
||||
version: 1.8.2
|
||||
auth:
|
||||
username: sentinel
|
||||
password: sentinel
|
Loading…
Reference in New Issue