当前位置: 首页 > 知识库问答 >
问题:

如何在springBoot版本1.5.15.release中配置lettuceConnectionFactory

东方弘壮
2023-03-14

我试图用1.5.15.release版本在Spring Boot项目中配置LettuceConnectionFactory。

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;

@SpringBootApplication
public class RedisApplication {

  private static final Logger LOGGER = LoggerFactory.getLogger(RedisApplication.class);

  @Bean
  public LettuceConnectionFactory lettuceConnectionFactory()
   {
      LOGGER.info("Setup lettuce config");
      final LettuceConnectionFactory factory = new LettuceConnectionFactory();
      return factory;
  }

  @Bean
  RedisTemplate<String,User> redisTemplate()
  {
    RedisTemplate<String,User> redisTemplate = new RedisTemplate<>();
    redisTemplate.setConnectionFactory(lettuceConnectionFactory());
    return redisTemplate;
  }

    public static void main(String[] args) {

        SpringApplication.run(RedisApplication.class, args);



    }

}
<dependency>
            <groupId>biz.paluch.redis</groupId>
            <artifactId>lettuce</artifactId>
            <version>3.5.0.Final</version>
        </dependency>

共有1个答案

叶举
2023-03-14

你的依赖是错误的。

尝试 io.lettuce lettuce-core ${lettuce.version}

 类似资料:
  • 我在学习Spring Boot时遇到了一些编码问题;我想添加一个像Spring3.x那样的CharacterEncodingFilter。就像这样:

  • 在jboss中配置日志记录的最佳方法是什么,我已经尝试了2种方法(都失败了):1.)使用jboss内置,根据一些文章我只需要添加对slf4j-api的依赖,就像提供的范围: *这里的问题是在eclipse控制台中没有显示日志。 2.)使用logback,所以我在jboss-deployment-structure.xml中排除了slf4j和impl,并且在我的war项目中包含了slf4j/logb

  • 我知道在DispatcherServlet之外使用请求范围bean需要一些配置,并且已经阅读了http://docs.spring.io/spring/docs/4.0.x/spring-framework-reference/html/beans.html#beans-factory-scopes-oth,但是还没有成功: 对于Servlet3.0+,这可以通过WebApplicationIni

  • 我想在android studio中配置,但我无法获得任何文档或链接。Github在许多可用于android的lib上,但都是旧版本。以及如何在Android中运行命令?我想知道在配置之后,如何运行命令。帮帮我。提前谢谢。

  • 目前移动统计iOS SDK默认统计的版本为AppStore中的版本号,即CFBundleShortVersionString的值。如果您有自己设置版本的需求,可以设置shortAppVersion属性的值。具体设置方法参见本文档基础配置部分。

  • 目前移动统计Android SDK默认统计的版本为AndroidManifest.xml中配置的版本号,即android:versionName="xxx"的值。 如果您希望自定义APP版本号,可以通过API StatService.setAppVersionName(Context context, String versionName)进行设置。一般建议无需此设置,除非特殊需要,比如对于SDK