spring-statemachine
spring-statemachine copied to clipboard
Consider defining a bean of type 'org.springframework.statemachine.data.jpa.JpaStateMachineRepository' in your configuration.
Hello guys. I hava tried to use state machine, and i'm stuck on this error: `*************************** APPLICATION FAILED TO START
Description:
Parameter 0 of method stateMachineRuntimePersister in com.bank.bank.loan.statemachine.LoanStateMachineConfig$JpaPersisterConfig required a bean of type 'org.springframework.statemachine.data.jpa.JpaStateMachineRepository' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.statemachine.data.jpa.JpaStateMachineRepository' in your configuration.
Process finished with exit code 0 `
Help me please hot to fix this.
I have used:
<spring-statemachine.version>2.2.3.RELEASE</spring-statemachine.version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
Spring-boot 3.0 is not compatible spring-statemachine 2.2.3. Spring data jpa with spring boot 3.0 depends on package of jakarta.persistence , instead of javax.persistence. Personally, I think that spring statemachine needs to wait for the release of a new version to support boot 3.0.
And spring boot 3.0 is not using spring.factories
to enable auto configure, I found that file still used in statemachine.
Recently, I also have encountered this problem when using statemachine version 3.2.0.
Make sure you have added the dataJpa dependency
It works if you add //@EnableJpaRepositories("org.springframework.statemachine.data.jpa") //@EntityScan("org.springframework.statemachine.data.jpa")
in your main method classs
I tried. It doesn't work.
for me this also works with mongodb, java 17 and spring boot 3 when using statemachine version 3.2.0: @EnableMongoRepositories({"org.springframework.statemachine.data.mongodb"}) @EntityScan("org.springframework.statemachine.data.mongodb")
but finally the statemachine library should be updated for compatibility with spring boot 3