java.lang.IllegalStateException:Bean工厂必须是ListableBeanFactory的实例,为null [英] java.lang.IllegalStateException: Bean factory must be instance of ListableBeanFactory, was null

查看:458
本文介绍了java.lang.IllegalStateException:Bean工厂必须是ListableBeanFactory的实例,为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用提供的生成器创建状态机对象,如下所示:

I'm creating a state machine object using the provided builder as follows:

10.2通过Builder的状态机

我看到以下异常:

10.2 State Machine via Builder

I'm seeing the following exception:

错误org.springframework.statemachine.support.StateMachineObjectSupport-无法初始化注释处理程序 java.lang.IllegalStateException:Bean工厂必须是ListableBeanFactory的实例,为空

ERROR org.springframework.statemachine.support.StateMachineObjectSupport - Unable to initialize annotation handlers java.lang.IllegalStateException: Bean factory must be instance of ListableBeanFactory, was null

该异常不会阻止状态机按预期运行.但是,我想深入了解为什么看到这一点.

The exception isn't preventing the state machine from functioning as expected. However, I would like to get down to the bottom of why I'm seeing this.

有人知道如何阻止此异常显示吗?

Anyone know how I can stop this exception from showing?

谢谢.

推荐答案

已设法解决此问题.

我将Spring应用程序上下文自动连接到我的类中.然后,我从中提取AutowireCapableBeanFactory并将其设置在构建器中.如下:

I autowired the the Spring application context into my class. I then extracted the AutowireCapableBeanFactory from this and set this up inside the builder. As follows:

   @Autowired
    private ApplicationContext appContext;

     private void buildStateMachine() throws Exception {
        Builder<EnquiryStatus, Event> builder = StateMachineBuilder.builder();
        builder.configureConfiguration().withConfiguration().beanFactory(appContext.getAutowireCapableBeanFactory());
     }

这篇关于java.lang.IllegalStateException:Bean工厂必须是ListableBeanFactory的实例,为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆