下面是我的一个类项目,它使用spring-statemachine-core-1.0.2.RELEASE-sources.jar,它实现了从一个状态到另一个状态的简单转换。它在 AbstractStateMachine.acceptEvent 方法中的 currentState 上咳嗽空指针异常。欣赏帮助/想法。
显示java.lang.NullPointerException 在org.springframework.statemachine.support.AbstractStateMachine.acceptEvent(AbstractStateMachine.java:591)
import java.util.Arrays;
import java.util.HashSet;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.config.StateMachineBuilder.Builder;
public class Processor {
public static void main(String[] args) throws Exception {
Builder<String, String> builder = StateMachineBuilder.builder();
builder.configureStates()
.withStates()
.initial("INIT").end("END")
.states(new HashSet<String>(Arrays.asList("INIT","MIDDLE","END")));
builder.configureTransitions()
.withExternal()
.source("INIT").target("MIDDLE").event("START")
.and()
.withExternal()
.source("MIDDLE").target("END");
builder.configureConfiguration().withConfiguration().autoStartup(true);
StateMachine<String, String> stateMachine = builder.build();
stateMachine.start();
stateMachine.sendEvent("START");
stateMachine.stop();
}
}
答案 0 :(得分:0)
是的,手动构建器机器没有获得默认taskExecutor
。它已经在master和1.0.x分支中修复,但我们还没有发布1.0.3。解决方法是手动设置:
builder
.configureConfiguration()
.withConfiguration()
.taskExecutor(new SyncTaskExecutor())
.autoStartup(true);