【发布时间】:2018-05-05 17:18:52
【问题描述】:
我正在尝试将 Lettuce 驱动程序与 Spring Boot 2 和 Spring Data Redis(均为最新版本)一起使用。我无法连接到 Redis,我不断收到以下错误:
Caused by: java.lang.ClassNotFoundException: io.lettuce.core.KeyValue
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_111]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_111]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_111]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_111]
... 148 common frames omitted
我想使用响应式连接,所以我要覆盖 connectionFactory,配置类
@Configuration
class RedisConfig {
@Bean
fun reactiveRedisConnection(redisConnectionFactory: ReactiveRedisConnectionFactory): ReactiveRedisConnection {
return redisConnectionFactory.reactiveConnection
}
@Bean
fun redisConnectionFactory(): LettuceConnectionFactory {
return LettuceConnectionFactory()
}
}
application.properties
## Redis config
spring.redis.host=192.168.99.100
spring.redis.port=32769
build.gradle
dependencies {
compile("org.springframework.boot:spring-boot-starter-webflux:${springBootVersion}")
compile('org.springframework.boot:spring-boot-starter-actuator')
compile("org.springframework.data:spring-data-redis")
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
compile("org.jetbrains.kotlin:kotlin-reflect")
compile("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.5")
runtime('org.springframework.boot:spring-boot-devtools')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
谢谢
【问题讨论】:
标签: spring-boot redis spring-data-redis