数据库
首页 > 数据库> > redission分布式锁配置

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

 

标签:RedissonConfigProperites,redisson,Config,配置,private,redissonConfigProperites,red
来源: https://www.cnblogs.com/stromgao/p/16318239.html