redission分布式锁配置
具体的详解参考:
https://xie.infoq.cn/article/d8e897f768eb1a358a0fd6300
SpringBoot配置类:
@Configuration public class RedissonConfig { @Resource private RedissonConfigProperites redissonConfigProperites; @Bean(destroyMethod="shutdown") RedissonClient redisson() { Config config = new Config(); config.useSingleServer() .setAddress(redissonConfigProperites.getAddress()) .setPassword(redissonConfigProperites.getPassword()) .setDatabase(redissonConfigProperites.getDatabase()); return Redisson.create(config); } }
@Data @Component @ConfigurationProperties(prefix = "redisson") public class RedissonConfigProperites { private String address; private String password; private int database; }
nacos配置:
redisson: address: redis://127.0.0.1:6379 password: 123456 database: 2
随笔看心情