Configuration Spring StateMachine配置:使用@EnableSateMachineFactory时命名StateMachine

Configuration Spring StateMachine配置:使用@EnableSateMachineFactory时命名StateMachine,configuration,factory,spring-statemachine,Configuration,Factory,Spring Statemachine,我想包括几个StateMachine配置,用于使用StateMachineFactory进行动态实例化。但是,@EnableStateMachineFactory注释允许命名工厂。如何命名每个配置(即扩展EnumStateMachineConfigureAdapter) 否则,如果可能的话,在配置定义中提供一个如何使用setMachineID方法的示例将非常有用 使用这些启用带有Spring `@Configuration'类的注释,只需定义在应用程序上下文中注册的bean名称。最容易用例子解释

我想包括几个
StateMachine
配置,用于使用
StateMachineFactory
进行动态实例化。但是,
@EnableStateMachineFactory
注释允许命名工厂。如何命名每个配置(即扩展
EnumStateMachineConfigureAdapter


否则,如果可能的话,在配置定义中提供一个如何使用
setMachineID
方法的示例将非常有用

使用这些
启用带有Spring `@Configuration'类的
注释,只需定义在应用程序上下文中注册的bean名称。最容易用例子解释:

@EnableStateMachine
StateMachine
作为bean
StateMachine

@EnableStateMachine(name = "fooMachine")
@EnableStateMachine(name = {StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, "fooMachine"})
@EnableStateMachineFactory
StateMachine
作为bean
fooMachine

@EnableStateMachine(name = "fooMachine")
@EnableStateMachine(name = {StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, "fooMachine"})
@EnableStateMachineFactory
StateMachine
作为bean
StateMachine
和bean别名
fooMachine

@EnableStateMachine(name = "fooMachine")
@EnableStateMachine(name = {StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, "fooMachine"})
@EnableStateMachineFactory
StateMachineFactory
作为bean
StateMachineFactory

@EnableStateMachineFactory(name = "fooMachineFactory")
@EnableStateMachineFactory(name = {StateMachineSystemConstants.DEFAULT_ID_STATEMACHINEFACTORY, "fooMachineFactory"})
StateMachineFactory
作为bean
fooMachineFactory

@EnableStateMachineFactory(name = "fooMachineFactory")
@EnableStateMachineFactory(name = {StateMachineSystemConstants.DEFAULT_ID_STATEMACHINEFACTORY, "fooMachineFactory"})
StateMachineFactory
作为bean
StateMachineFactory
和bean别名
fooMachineFactory

@EnableStateMachineFactory(name = "fooMachineFactory")
@EnableStateMachineFactory(name = {StateMachineSystemConstants.DEFAULT_ID_STATEMACHINEFACTORY, "fooMachineFactory"})
除此之外,
@Configuration
类(扩展StateMachineConfigureAdapter)的名称并不重要。在Spring中,
@Configuration
类也被创建为bean,这意味着在Spring应用程序上下文中,下面的类将作为bean
myConfig.MachineFactoryConfig
存在。在Spring中只需记住一件事,因为名称不正确的类可能导致bean重写

public class MyConfig {
  @Configuration
  @EnableStateMachineFactory
  public static class MachineFactoryConfig extends StateMachineConfigurerAdapter<String, String> {
  }
}
公共类MyConfig{
@配置
@EnableStateMachineFactory
公共静态类MachineFactoryConfig扩展了StateMachineConfigureAdapter{
}
}

我刚刚在文档中添加了一个新的部分。(仅在快照构建中,直到我们发布下一个版本)

让这些
启用带有Spring `@Configuration'类的注释,只需定义在应用程序上下文中注册的bean名称。最容易用例子解释:

@EnableStateMachine
StateMachine
作为bean
StateMachine

@EnableStateMachine(name = "fooMachine")
@EnableStateMachine(name = {StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, "fooMachine"})
@EnableStateMachineFactory
StateMachine
作为bean
fooMachine

@EnableStateMachine(name = "fooMachine")
@EnableStateMachine(name = {StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, "fooMachine"})
@EnableStateMachineFactory
StateMachine
作为bean
StateMachine
和bean别名
fooMachine

@EnableStateMachine(name = "fooMachine")
@EnableStateMachine(name = {StateMachineSystemConstants.DEFAULT_ID_STATEMACHINE, "fooMachine"})
@EnableStateMachineFactory
StateMachineFactory
作为bean
StateMachineFactory

@EnableStateMachineFactory(name = "fooMachineFactory")
@EnableStateMachineFactory(name = {StateMachineSystemConstants.DEFAULT_ID_STATEMACHINEFACTORY, "fooMachineFactory"})
StateMachineFactory
作为bean
fooMachineFactory

@EnableStateMachineFactory(name = "fooMachineFactory")
@EnableStateMachineFactory(name = {StateMachineSystemConstants.DEFAULT_ID_STATEMACHINEFACTORY, "fooMachineFactory"})
StateMachineFactory
作为bean
StateMachineFactory
和bean别名
fooMachineFactory

@EnableStateMachineFactory(name = "fooMachineFactory")
@EnableStateMachineFactory(name = {StateMachineSystemConstants.DEFAULT_ID_STATEMACHINEFACTORY, "fooMachineFactory"})
除此之外,
@Configuration
类(扩展StateMachineConfigureAdapter)的名称并不重要。在Spring中,
@Configuration
类也被创建为bean,这意味着在Spring应用程序上下文中,下面的类将作为bean
myConfig.MachineFactoryConfig
存在。在Spring中只需记住一件事,因为名称不正确的类可能导致bean重写

public class MyConfig {
  @Configuration
  @EnableStateMachineFactory
  public static class MachineFactoryConfig extends StateMachineConfigurerAdapter<String, String> {
  }
}
公共类MyConfig{
@配置
@EnableStateMachineFactory
公共静态类MachineFactoryConfig扩展了StateMachineConfigureAdapter{
}
}

我刚刚在文档中添加了一个新的部分。(仅在快照构建中,直到我们发布下一个版本)

如果您有内联代码,请用反勾(
`
)标记它。这有助于使您的问题更具可读性。如果您有内联代码,请用反勾(
`
)标记它。这有助于使你的问题更具可读性。