|
|
|
|
@ -3,18 +3,35 @@ package org.springblade.lims.config; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import org.springblade.lims.tools.RedisUtil; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
import org.springframework.data.redis.connection.RedisStandaloneConfiguration; |
|
|
|
|
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; |
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
|
@RequiredArgsConstructor(onConstructor = @__(@Autowired)) |
|
|
|
|
public class RedisToolConfig { |
|
|
|
|
|
|
|
|
|
@Value("${spring.redis.host}") |
|
|
|
|
private String host; |
|
|
|
|
|
|
|
|
|
@Value("${spring.redis.port}") |
|
|
|
|
private int port; |
|
|
|
|
|
|
|
|
|
@Value("${spring.redis.password}") |
|
|
|
|
private String password; |
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
@Bean(name = "redisUtil") |
|
|
|
|
public RedisUtil redisUtil() { |
|
|
|
|
RedisStandaloneConfiguration redisConfig = new RedisStandaloneConfiguration(host,port); |
|
|
|
|
redisConfig.setPassword(password); |
|
|
|
|
LettuceConnectionFactory factory = new LettuceConnectionFactory(redisConfig); |
|
|
|
|
factory.afterPropertiesSet(); |
|
|
|
|
redisTemplate.setConnectionFactory(factory); |
|
|
|
|
return new RedisUtil(redisTemplate); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|