网站首页
Java
站长
开源
框架
理论
JS
Linux
DB
服务器
网络编程
生活
软件
PHP
其他
回复Java小强

可以写一个配置类 package com.example.springboot.tool; import org.redisson.Redisson; import org.redisson.api.RedissonClient; import org.redisson.config.Config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; import java.io.IOException; /** * @Auther: Java小强 * @Date: 2022/1/28 - 10:29 * @Decsription: com.example.springboot.tool * @Version: 1.0 */ @Configuration public class InitializingRedis{     @Bean     public RedissonClient getRedissonClient() throws IOException {         ResourceLoader loader = new DefaultResourceLoader();         Resource resource = loader.getResource("classpath:redisson.yml");         Config config = Config.fromYAML(resource.getInputStream());         config.useClusterServers();         return Redisson.create(config);     } }

您的网名:
个人主页:
编辑内容: