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

创建名为“…RedishttpsessionConfiguration”的bean时出错:bean初始化失败

锺离俊雄
2023-03-14
@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':

bean初始化失败

更多跟踪:

原因:org.springframework.beans.factory.unsatisfiedDependencyException:创建类路径资源[org/springframework/boot/autocconfigure/session/sessionrepositoryfilterconfiguration.class]中定义的名为“sessionrepositoryfilterregistration”的bean时出错:通过方法“sessionrepositoryfilterregistration”的参数%1表示的不满足的依赖关系;嵌套异常为org.springframework.beans.factory.beanCreationException:创建名为“org.springframework.session.data.redis.config.annotation.web.http.redishttpsessionConfiguration”的bean时出错:bean初始化失败;嵌套异常为org.springframework.beans.factory.BeanCreationException:创建类路径资源[bookstore/config/httpsessionconfig.class]中定义的名为“Connection factory”的bean时出错:通过工厂方法实例化bean失败;嵌套异常为org.springframework.beans.beanInstantiationException:无法实例化[org.springframework.data.redis.connection.lettuceConnectionFactory]:工厂方法“Connection Factory”引发异常;嵌套异常是java.lang.NoClassDefoundError:io/lettuce/core/keyvalue

Caused by: org.springframework.beans.factory.BeanCreationException: Error

创建名为“org.springframework.session.data.redis.config.annotation.web.http.redishttpsessionconfiguration”的bean:bean初始化失败;嵌套异常为org.springframework.beans.factory.BeanCreationException:创建类路径资源[bookstore/config/httpsessionconfig.class]中定义的名为“Connection factory”的bean时出错:通过工厂方法实例化bean失败;嵌套异常为org.springframework.beans.beanInstantiationException:无法实例化[org.springframework.data.redis.connection.lettuceConnectionFactory]:工厂方法“Connection Factory”引发异常;嵌套异常是java.lang.NoClassDefoundError:io/lettuce/core/keyvalue

有人知道怎么修吗???

共有1个答案

贺经纶
2023-03-14

在堆栈跟踪中,错误告诉

noClassDefoundError:io/lettuce/core/keyvalue

因此在pom.xml中手动添加依赖项io.lettuce

<dependency>
    <groupId>io.lettuce</groupId>
    <artifactId>lettuce-core</artifactId>
    <version>5.1.7.RELEASE</version>
</dependency>
 类似资料:
  • 完全错误: BeanCreationException:创建名为“Transaction ManagerPostProcessor”的bean时出错:bean初始化失败;嵌套异常是org.springframework.beans.factory.beanCreationException:创建名为“事务管理器”的bean时出错:在设置bean属性“会话工厂”时无法解析对bean“会话工厂”的引用

  • 问题内容: 我正在使用Spring和Hibernate开发一个全栈Web应用程序。尝试运行一些测试代码,但我不断收到此错误。这是完整的堆栈跟踪: 这是我的Spring安装文件: 我的测试代码: 和我的pom文件: 需要帮助请叫我。TIA。 问题答案: 您应该更新您的POM并使用较新版本的hibernate- core。您使用的版本太旧并且没有软件包。切换到4.3.0.Final或更高版本。 更新:

  • 为什么自动加载依赖项的注入失败。 严重:上下文初始化失败。springframework。豆。工厂BeanCreationException:创建名为“homeController”的bean时出错:自动连线依赖项的注入失败;嵌套的异常是org。springframework。豆。工厂BeanCreationException:无法自动关联字段:com。快速启动。通用域名格式。springmvc。

  • 我有一个实体类InAppNotification。看起来像这样的java: 我使用JPA来处理数据库查询,这就是JPA接口的定义: 这是我application.properties的样子: 但是,当我试图在构建后通过运行 来打包应用程序时,我会遇到以下问题: 尝试调用不存在的方法。尝试从以下位置进行:javax.el.ELManager.getExpress sionWorks(ELManage

  • 在将project从Spring Boot版本从1.2.3.release迁移到1.3.0.release之后,我已经开始得到以下异常。 创建类路径资源[org/springframework/boot/autoconfigure/admin/springapplicationadminjmxautoconfiguration.class]中定义的名为'Spring ApplicationAdmi

  • 我遵循本教程将消息发送到azure服务队列:https://docs.microsoft.com/en-us/azure/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-service-bus 到我现有的spring boot应用程序,但我得到以下错误: 用户类别: 控制器类: pom xml: 添加它