mirror of https://gitee.com/y_project/RuoYi-Vue
Pre Merge pull request !1002 from Engineer/master
This commit is contained in:
commit
42f169e616
8
pom.xml
8
pom.xml
|
@ -35,6 +35,7 @@
|
|||
<logback.version>1.2.13</logback.version>
|
||||
<spring-security.version>5.7.12</spring-security.version>
|
||||
<spring-framework.version>5.3.39</spring-framework.version>
|
||||
<redisson.version>3.23.4</redisson.version>
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
|
@ -183,6 +184,13 @@
|
|||
<version>${kaptcha.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- redisson -->
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson</artifactId>
|
||||
<version>${redisson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 定时任务-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
|
|
|
@ -43,6 +43,12 @@
|
|||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- redisson -->
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 核心模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package com.ruoyi.web.core.config;
|
||||
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.redisson.Redisson;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.config.Config;
|
||||
import org.redisson.config.SingleServerConfig;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Redisson 配置
|
||||
*
|
||||
* @author Engineer
|
||||
*/
|
||||
@Configuration
|
||||
public class RedissonConfig {
|
||||
|
||||
private final static String REDIS_URL_FORMAT = "redis://%s:%s";
|
||||
|
||||
@Value("${spring.redis.host:}")
|
||||
private String host;
|
||||
|
||||
@Value("${spring.redis.port:6379}")
|
||||
private Integer port;
|
||||
|
||||
@Value("${spring.redis.password:}")
|
||||
private String password;
|
||||
|
||||
@Value("${spring.redis.cluster.nodes:}")
|
||||
private String[] nodes;
|
||||
|
||||
@Bean
|
||||
public RedissonClient redissonClient() {
|
||||
Config config = new Config();
|
||||
SingleServerConfig config2 = config.useSingleServer();
|
||||
|
||||
String redisUrl = String.format(REDIS_URL_FORMAT, this.host, this.port);
|
||||
config2.setAddress(redisUrl);
|
||||
|
||||
if (StringUtils.isNotBlank(password)){
|
||||
config2.setPassword(password);
|
||||
}
|
||||
|
||||
return Redisson.create(config);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue