[英]Spring State machine JPA persistence
我是Spring狀態機的新手我有下面給出的狀態配置我需要在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在運行時顯示清潔模型持久性機器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.