- 部分POM.XML
... <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.3.RELEASE</version> </parent> ... <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> ...
- 配置订阅
/** 订阅配置 channel1是频道,可以多个 也可以patternToppic */ @Configuration public class MyRedisMessageListenerContainer { @Bean MessageListenerAdapter messageListener() { return new MessageListenerAdapter(new MySubcribe()); } @Bean RedisMessageListenerContainer redisContainer(RedisConnectionFactory factory) { final RedisMessageListenerContainer container = new RedisMessageListenerContainer(); container
SpringBoot redisTemplate 实现基础订阅与发布
最新推荐文章于 2024-07-22 11:31:44 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)