spring-projects / spring-data-r2dbc

Provide support to increase developer productivity in Java when using Reactive Relational Database Connectivity. Uses familiar Spring concepts such as a DatabaseClient for core API usage and lightweight repository style data access.
Apache License 2.0
708 stars 132 forks source link

Repositories not detected by @EnableR2dbcRepositories annotation #862

Closed sons-of-titus closed 1 month ago

sons-of-titus commented 1 month ago

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:

mp911de commented 1 month ago

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal yet complete sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

spring-projects-issues commented 1 month ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues commented 1 month ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.