Skip to content

Name R2dbcEntityTemplate explicitly #354

Open
@peterfigure

Description

@peterfigure

I believe this isn't fully supported yet but attempting to use r2dbc DSL with repositories, pretty close but I believe it wants the R2dbcEntityTemplate bean named "r2dbcEntityTemplate" explicitly:

https://github.com/spring-projects/spring-data-r2dbc/blob/1.2.x/src/main/java/org/springframework/data/r2dbc/repository/config/EnableR2dbcRepositories.java#L139

19:31:29.421 [restartedMain] WARN  o.s.b.w.r.c.AnnotationConfigReactiveWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contractLifecycleRepository' defined in com.xxx.ContractLifecycleRepository 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.NoSuchBeanDefinitionException: No bean named 'r2dbcEntityTemplate' available

When creating the beans manually in lieu of using r2dbc DSL I run into the same problem and it's resolved by naming it explicitly:

        bean<R2dbcEntityTemplate>("r2dbcEntityTemplate") {
            ref<R2dbcDataAutoConfiguration>().r2dbcEntityTemplate(ref())
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions