Spring R2DBC Repos 自动配置未解析依赖项
Spring R2DBC Repos auto configuration not resolving dependencies
我有以下存储库:https://github.com/vlio20/bfit 我在其中尝试使用 R2DBC 以异步方式执行数据库操作。
我遵循了以下教程(但可能已经过时 https://www.youtube.com/watch?v=DvO4zLVDkMs
以下是我的 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>
我使用的是默认配置,所以我的属性yaml中只有以下配置:
server:
port: 2121
spring:
profiles:
active: ${env:default}
r2dbc:
url: r2dbc:mysql://localhost:3306/bf_db
username: root
password: root
app:
name: Bfit
这是我得到的错误:
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
这是完整的堆栈跟踪:https://pastebin.com/X4DGm4rQ
如错误信息:
java.lang.NoClassDefFoundError: org/springframework/data/convert/JodaTimeConverters
提到,您错过了 spring-data-commons
罐子。添加为依赖,错误应该解决
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
我有以下存储库:https://github.com/vlio20/bfit 我在其中尝试使用 R2DBC 以异步方式执行数据库操作。 我遵循了以下教程(但可能已经过时 https://www.youtube.com/watch?v=DvO4zLVDkMs
以下是我的 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>
我使用的是默认配置,所以我的属性yaml中只有以下配置:
server:
port: 2121
spring:
profiles:
active: ${env:default}
r2dbc:
url: r2dbc:mysql://localhost:3306/bf_db
username: root
password: root
app:
name: Bfit
这是我得到的错误:
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
这是完整的堆栈跟踪:https://pastebin.com/X4DGm4rQ
如错误信息:
java.lang.NoClassDefFoundError: org/springframework/data/convert/JodaTimeConverters
提到,您错过了 spring-data-commons
罐子。添加为依赖,错误应该解决
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>