repository. - Enable Redis Http Session - Embedded Redis Settings - Refactor integration tests
34 lines
1.1 KiB
Java
34 lines
1.1 KiB
Java
package com.yam.app.common.configuration;
|
|
|
|
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.RedisConnectionFactory;
|
|
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
|
|
|
|
@Configuration
|
|
@EnableRedisHttpSession
|
|
public class RedisConfiguration {
|
|
|
|
@Value("${spring.redis.host}")
|
|
private String redisHost;
|
|
|
|
@Value("${spring.redis.port}")
|
|
private int redisPort;
|
|
|
|
@Bean
|
|
public RedisConnectionFactory redisConnectionFactory() {
|
|
return new LettuceConnectionFactory(redisHost, redisPort);
|
|
}
|
|
|
|
@Bean
|
|
public RedisTemplate<byte[], byte[]> redisTemplate() {
|
|
RedisTemplate<byte[], byte[]> redisTemplate = new RedisTemplate<>();
|
|
redisTemplate.setConnectionFactory(redisConnectionFactory());
|
|
return redisTemplate;
|
|
}
|
|
|
|
}
|