2017-12-02 296 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在運行時顯示更清潔的模型持久機器。