spring-projects / spring-statemachine

Spring Statemachine is a framework for application developers to use state machine concepts with Spring.
1.52k stars 598 forks source link

Consider defining a bean of type 'org.springframework.statemachine.data.jpa.JpaStateMachineRepository' in your configuration. #1087

Open Spartaques opened 1 year ago

Spartaques commented 1 year ago

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:

2.2.3.RELEASE org.springframework.boot spring-boot-starter-parent 3.0.1
royalzzz commented 1 year ago

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.

chakradhar4 commented 1 year ago

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

royalzzz commented 1 year ago

I tried. It doesn't work.

schmittcn commented 1 year ago

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