diff --git a/docker-compose.yml b/docker-compose.yml index 9820531c..d65aa759 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: @@ -39,4 +43,10 @@ services: image: jeecg-boot-system hostname: jeecg-boot-system ports: - - 8080:8080 \ No newline at end of file + - 8080:8080 + networks: + - jeecg-boot + +networks: + jeecg-boot: + name: jeecg_boot diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java b/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java index 1e205a11..4ca3ddf5 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java @@ -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(); diff --git a/jeecg-server-cloud/jeecg-visual/jeecg-cloud-sentinel/src/main/java/com/alibaba/csp/sentinel/dashboard/JeecgSentinelApplication.java b/jeecg-server-cloud/jeecg-visual/jeecg-cloud-sentinel/src/main/java/com/alibaba/csp/sentinel/dashboard/JeecgSentinelApplication.java index 64d78814..a64b50a4 100644 --- a/jeecg-server-cloud/jeecg-visual/jeecg-cloud-sentinel/src/main/java/com/alibaba/csp/sentinel/dashboard/JeecgSentinelApplication.java +++ b/jeecg-server-cloud/jeecg-visual/jeecg-cloud-sentinel/src/main/java/com/alibaba/csp/sentinel/dashboard/JeecgSentinelApplication.java @@ -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" + diff --git a/jeecg-server-cloud/jeecg-visual/jeecg-cloud-sentinel/src/main/resources/application.yml b/jeecg-server-cloud/jeecg-visual/jeecg-cloud-sentinel/src/main/resources/application.yml index 551dd725..017cd904 100644 --- a/jeecg-server-cloud/jeecg-visual/jeecg-cloud-sentinel/src/main/resources/application.yml +++ b/jeecg-server-cloud/jeecg-visual/jeecg-cloud-sentinel/src/main/resources/application.yml @@ -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: @@ -34,4 +32,7 @@ nacos: ip: @config.server-addr@ sentinel: dashboard: - version: 1.8.2 \ No newline at end of file + version: 1.8.2 + auth: + username: sentinel + password: sentinel \ No newline at end of file