spring-statemachine icon indicating copy to clipboard operation
spring-statemachine copied to clipboard

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

Open Spartaques opened this issue 2 years ago • 4 comments

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> 3.0.1

Spartaques avatar Feb 19 '23 14:02 Spartaques

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.

royalzzz avatar Mar 04 '23 07:03 royalzzz

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

chakradhar4 avatar Mar 15 '23 05:03 chakradhar4

I tried. It doesn't work.

royalzzz avatar Mar 22 '23 02:03 royalzzz

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

schmittcn avatar May 15 '23 05:05 schmittcn