问题描述
我正在使用提供的生成器创建状态机对象,如下所示:
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:
该异常不会阻止状态机按预期运行.但是,我想深入了解为什么看到这一点.
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!