- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在使用 Redis 并创建了 HttpSessionConfig
文件。这是我在
HttpSessionConfig.java
:
@EnableRedisHttpSession
public class HttpSessionConfig {
@Bean
public LettuceConnectionFactory connectionFactory() {
return new LettuceConnectionFactory();
}
@Bean
public HttpSessionIdResolver httpSessionStrategy() {
return HeaderHttpSessionIdResolver.authenticationInfo();
}
}
这是我的pom.xml
文件:
<!-- Redis -->
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<dependency>
<groupId>biz.paluch.redis</groupId>
<artifactId>lettuce</artifactId>
<version>4.3.1.Final</version>
</dependency>
但是我得到了错误:
Error creating bean with name 'org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration':
Initialization of bean failed
更多痕迹:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionRepositoryFilterRegistration' defined in class path resource [org/springframework/boot/autoconfigure/session/SessionRepositoryFilterConfiguration.class]: Unsatisfied dependency expressed through method 'sessionRepositoryFilterRegistration' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connectionFactory' defined in class path resource [bookstore/config/HttpSessionConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory]: Factory method 'connectionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: io/lettuce/core/KeyValue
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connectionFactory' defined in class path resource [bookstore/config/HttpSessionConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory]: Factory method 'connectionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: io/lettuce/core/KeyValue
有人知道怎么解决吗???
最佳答案
在堆栈跟踪中,错误告诉我们
java.lang.NoClassDefFoundError: io/lettuce/core/KeyValue
所以手动添加依赖io.lettuce在你的 pom.xml 中
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>5.1.7.RELEASE</version>
</dependency>
关于java - 创建名称为 '...RedisHttpSessionConfiguration' 的 bean 时出错 : Initialization of bean failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56823341/
我正在使用 spring-boot 和 spring-session 构建一个简单的 rest api。生产应用程序应使用 redis-session 实现,而测试应使用默认(非 Redis)spri
我遇到的问题与 https://github.com/spring-projects/spring-session/issues/438 中描述的完全相同,我试图将特定的 JedisConnectio
我正在使用 Redis 并创建了 HttpSessionConfig 文件。这是我在 中的代码 HttpSessionConfig.java: @EnableRedisHttpSession publ
我是一名优秀的程序员,十分优秀!