spring-data-redis-example
kandi X-RAY | spring-data-redis-example Summary
kandi X-RAY | spring-data-redis-example Summary
spring-data-redis-example
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of spring-data-redis-example
spring-data-redis-example Key Features
spring-data-redis-example Examples and Code Snippets
Community Discussions
Trending Discussions on spring-data-redis-example
QUESTION
@Configuration
public class RedisConfig {
@Bean
JedisConnectionFactory jedisConnectionFactory() {
return new JedisConnectionFactory();
}
@Bean
public RedisTemplate redisTemplate() {
final RedisTemplate template = new RedisTemplate();
template.setConnectionFactory(jedisConnectionFactory());
template.setValueSerializer(new GenericToStringSerializer(Object.class));
return template;
}
@Bean
MessageListenerAdapter messageListener() {
return new MessageListenerAdapter(new MessageSubscriber());
}
@Bean
RedisMessageListenerContainer redisContainer() {
final RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(jedisConnectionFactory());
container.addMessageListener(messageListener(), topic());
return container;
}
@Bean
MessagePublisher redisPublisher() {
return new MessagePublisherImpl(redisTemplate(), topic());
}
@Bean
ChannelTopic topic() {
return new ChannelTopic("pubsub:queue");
}
}
for Docker-container
...ANSWER
Answered 2020-Aug-11 at 05:19You config works for me. Not sure why.
Still, you can try Lettuce.
Swap your config file for this and see if works.
QUESTION
- pom.xml
ANSWER
Answered 2020-Aug-12 at 19:00you didn't set a key serializer, so it uses the JDK serializer as default. So the key was not actually stored as String in Redis server.
Change your code in the config about redis to this and try again.
QUESTION
I am using Spring Data Redis example. In this example, simply trying to connect to the redis DB. Runnning the main method, I am getting below error.
Spring Boot version used is v 2.0.3.RELEASE & Redis version is 2.4.5.
Code reference taken from : http://javasampleapproach.com/spring-framework/spring-data/spring-data-redis-example-spring-boot-redis-example and https://docs.spring.io/spring-session/docs/current/reference/html5/guides/boot-redis.html. Can anybody please suggest what is wrong here ?
...ANSWER
Answered 2018-Jul-14 at 17:34Your example is referencing boot 1.5.X
which uses Jedis
, by default lettuce
is used in Boot 2.0
if you want to use Jedis
you need to manually add the dependency. Additionally you can see that Jedis
isn't on your classpath and lettuce
is.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install spring-data-redis-example
You can use spring-data-redis-example like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the spring-data-redis-example component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page