spring-bootspring-statemachine

Could not autowire. No beans of 'StateMachineFactory<States, Events>' type found


@Configuration
@EnableStateMachineFactory
public class StateMachineConfig extends EnumStateMachineConfigurerAdapter
    <States, Events> {
    // configuring...
}

public enum Events {
    CONFIRM_RESET,
    CANCEL_RESET
    // other events
}

public enum States {
    INITIAL,
    STARTING_ORDER
    // other states
}

@Service
@Slf4j
public class OrderService {
    @Autowired
    private StateMachineFactory<States, Events> stateMachineFactory;

    // Could not autowire. No beans of 'StateMachineFactory<States, Events>' type found.
}

@EnableStateMachineFactory annotation does not work. Could not autowire. No beans of StateMachineFactory<States, Events>' type found.

In the same time after using @EnableStateMachine I can autowire 1 statemachine.


Solution

  • <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
        <version>2.5.4</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.statemachine</groupId>
        <artifactId>spring-statemachine-starter</artifactId>
        <version>3.0.1</version>
    </dependency>

    This solved my problem