企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
默认Guns在部署分布式的环境中使用了Redis作为分布式session的存储,如果想在项目中用redis做缓存或者存储,建议使用RedisTemplate来进行操作 1.首先下载Redis服务端,可以在Guns的qq群里找到redis的可执行包,或者去redis官网下载  2.在guns-admin项目添加对redis的依赖如下 1. `<dependency>` 2. `<groupId>org.springframework.boot</groupId>` 3. `<artifactId>spring-boot-starter-data-redis</artifactId>` 4. `</dependency>` 3.在`application.yml`中配置redis的连接属性  ![image_1c4teiq7e1ksl1tne1bn6159h1c9c1g.png-11.1kB](https://img-blog.csdnimg.cn/20181228174639723)  4.在`GunsApplication`类中,注入RedisTemplate,并编写`CommandLineRunner`来测试一下Redis的连接,如下 ``` @Bean CommandLineRunner commandLineRunner() { return new CommandLineRunner() { @Override public void run(String... strings) throws Exception { BoundValueOperations<String, Object> test = redisTemplate.boundValueOps("test"); test.set("test value"); Object o = test.get(); System.out.println(o); } }; } ```