0
我是Spring新狀態機我有下面給出的狀態配置我需要在mysql中使用JPA持久化狀態更改。任何適當的例子也對我非常有幫助。在此先感謝Spring狀態機JPA持久性
@Configuration
@EnableStateMachine(name = "machine1")
public class Config extends StateMachineConfigurerAdapter<String, String>{
@Override
public void configure(StateMachineConfigurationConfigurer<String, String> config) throws Exception {
config.withConfiguration().autoStartup(true).listener(listener());
}
@Override
public void configure(StateMachineStateConfigurer<String, String> states) throws Exception {
states
.withStates()
.initial("S1")
.state("S1")
.state("S2",null,action1())
.state("S3");
}
@Override
public void configure(StateMachineTransitionConfigurer<String, String> transitions) throws Exception {
transitions
.withExternal()
.source("S1")
.target("S2")
.event("E1")
.and().withExternal()
.source("S2")
.target("S3")
.event("E2");
}
}