在调用statemachine.start()
时,我总是得到下面的堆栈跟踪。但它并没有停止我的状态机执行,因为我没有使用任何注释进行状态转换,状态输入等。
请帮我解决这个错误。
19:41:56.515 ERROR o.s.s.s.StateMachineObjectSupport - Unable to initialize annotation handlers
java.lang.IllegalStateException: Bean factory must be instance of ListableBeanFactory, was null
at org.springframework.util.Assert.state(Assert.java:392) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.statemachine.processor.StateMachineHandlerCallHelper.setBeanFactory(StateMachineHandlerCallHelper.java:93) ~[spring-statemachine-core-1.1.1.BUILD-SNAPSHOT.jar:1.1.1.BUILD-SNAPSHOT]
at org.springframework.statemachine.support.StateMachineObjectSupport.doStart(StateMachineObjectSupport.java:66) ~[spring-statemachine-core-1.1.1.BUILD-SNAPSHOT.jar:1.1.1.BUILD-SNAPSHOT]
at org.springframework.statemachine.support.AbstractStateMachine.doStart(AbstractStateMachine.java:317) [spring-statemachine-core-1.1.1.BUILD-SNAPSHOT.jar:1.1.1.BUILD-SNAPSHOT]
at org.springframework.statemachine.support.LifecycleObjectSupport.start(LifecycleObjectSupport.java:120) [spring-statemachine-core-1.1.1.BUILD-SNAPSHOT.jar:1.1.1.BUILD-SNAPSHOT]
at org.tiaa.devops.process.delegate.StateMachineDelegateImpl.execute(StateMachineDelegateImpl.java:103) [classes/:na]
at org.tiaa.devops.process.delegate.StateMachineDelegateImpl.executePipeline(StateMachineDelegateImpl.java:67) [classes/:na]
at org.tiaa.devops.process.delegate.StateMachineDelegateImpl.lambda$0(StateMachineDelegateImpl.java:59) [classes/:na]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_66]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_66]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_66]
at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_66]
答案 0 :(得分:0)
管理以获得解决方案。
我将Spring应用程序上下文自动安装到我的课程中。然后我从中提取AutowireCapableBeanFactory并在构建器中设置它。如下:
@Autowired
private ApplicationContext appContext;
private void buildStateMachine() throws Exception {
Builder<EnquiryStatus, Event> builder = StateMachineBuilder.builder();
builder.configureConfiguration().withConfiguration().beanFactory(appContext.getAutowireCapableBeanFactory());
}