春季状态机JPA持久性



我是春季状态机的新手,我的状态配置下面给出了我需要在MySQL中使用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");
}   
}

jpa-config只是一个示例,将机器配置(状态,过渡等)保存在DB中。如果您使用制作配置的其他方式(Javadsl或UML),则不需要此。这种支持增加了,因为有些人希望有一种方法可以修改机器配置而无需再次汇编资源。我目前正在通过通过相同类型的弹簧数据存储库摘要为持久计算机提供更好的支持,这应该落在1.2.8。

中。

其他一些示例是一些示例,如何手动完成操作。目前,此过程确实是非常手动的,低水平的,而且很麻烦。如果您不在匆忙中,我建议您使用1.2.x分支的1.2.8快照。即,有新的示例datajpapersist显示了运行时清洁器模型持续存在的机器。

最新更新