Home > Software engineering >  Spring R2DBC Repos auto configuration not resolving dependencies
Spring R2DBC Repos auto configuration not resolving dependencies

Time:02-25

I Have the following repository: https://github.com/vlio20/bfit in which I try to use R2DBC in order to do db operations in an async manner. I followed the following tutorial (but maybe it is outdated https://www.youtube.com/watch?v=DvO4zLVDkMs

Here are the relevant dependancies of my pom:

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-r2dbc</artifactId>
  <version>1.4.2</version>
</dependency>

<dependency>
  <groupId>com.github.jasync-sql</groupId>
  <artifactId>jasync-r2dbc-mysql</artifactId>
  <version>2.0.6</version>
</dependency>

I am using the default configurations, so I only have the following configuration in my properties yaml:

server:
  port: 2121

spring:
  profiles:
    active: ${env:default}

  r2dbc:
    url: r2dbc:mysql://localhost:3306/bf_db
    username: root
    password: root

app:
  name: Bfit

And this is the error that I am getting:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController' defined in file [/Users/vioffe/personal/bfit/api/target/classes/com/bfit/api/user/controller/UserController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userService' defined in file [/Users/vioffe/personal/bfit/api/target/classes/com/bfit/api/user/service/UserService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepo' defined in com.bfit.api.user.db.UserRepo defined in @EnableR2dbcRepositories declared on R2dbcRepositoriesAutoConfigureRegistrar.EnableR2dbcRepositoriesConfiguration: Cannot resolve reference to bean 'r2dbcEntityTemplate' while setting bean property 'entityOperations'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'r2dbcEntityTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/r2dbc/R2dbcDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'r2dbcEntityTemplate' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'r2dbcConverter' defined in class path resource [org/springframework/boot/autoconfigure/data/r2dbc/R2dbcDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'r2dbcConverter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'r2dbcMappingContext' defined in class path resource [org/springframework/boot/autoconfigure/data/r2dbc/R2dbcDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'r2dbcMappingContext' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'r2dbcCustomConversions' defined in class path resource [org/springframework/boot/autoconfigure/data/r2dbc/R2dbcDataAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.r2dbc.convert.R2dbcCustomConversions]: Factory method 'r2dbcCustomConversions' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/convert/JodaTimeConverters

Here is the full stack trace: https://pastebin.com/X4DGm4rQ

CodePudding user response:

As the error message:

 java.lang.NoClassDefFoundError: org/springframework/data/convert/JodaTimeConverters

mentioned, you miss the spring-data-commons jar. Add it as dependency and the error should be solved.

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-commons</artifactId>
</dependency>
  • Related