Skip to content

Repositories not detected by @EnableR2dbcRepositories annotation #862

Closed as not planned
@sons-of-titus

Description

@sons-of-titus

Description

The @EnableR2dbcRepositories annotation is not detecting and initializing my R2DBC repositories as expected. This is preventing my application from properly interacting with the database using Spring Data R2DBC.

Current Behavior

When starting the application, no beans are created for my repository interfaces. This results in NoSuchBeanDefinitionException when trying to autowire these repositories.

Expected Behavior

The @EnableR2dbcRepositories annotation should detect all interfaces extending CoroutineCrudRepository (or other Spring Data R2DBC repository interfaces) within the specified base packages, and create the necessary beans for these repositories.

Steps to Reproduce

  1. Annotated main application class or configuration class with @EnableR2dbcRepositories.
  2. Created repository interfaces extending CoroutineCrudRepository in a submodule.
  3. Attempted to autowire these repositories in service classes.
  4. Started the application.

Code Snippets

Main Application Class:

@SpringBootApplication(scanBasePackages = ["mr.hawel"])
@EnableR2dbcRepositories(basePackages = ["mr.hawel.user.persistence"])
class MyApplication

fun main(args: Array<String>) {
    runApplication<MyApplication>(*args)
}

UserR2dbcRepository Interface:

@Repository
interface UserR2dbcRepository : CoroutineCrudRepository<UserEntity, UUID> {
    suspend fun findByPhoneNumber(phoneNumber: String): UserEntity?
}

Versions:

  • spring-boot-starter-data-r2dbc : 3.3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions