2017-12-02 102 views
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"); 
} 

} 

回答

1

jpa-config只是一个例子在一个数据库中保持机器配置(状态,转换等)。如果您使用其他方式(javadsl或uml)进行配置,则不需要此操作。这种支持正在增加,因为有些人希望有一种方法来修改机器配置,而无需再次编译源代码。我目前正在努力通过相同类型的弹簧数据存储库抽象为持久化机器添加更好的支持,这应该在1.2.8版本中着陆。

其他一些示例是一些示例,可以如何手动完成。目前这个过程确实是非常手动,低水平,相当麻烦。如果你不急于使用,我建议使用1.2.x分支的1.2.8快照。即有新的样本datajpapersist在运行时显示更清洁的模型持久机器。