https://kotlinlang.org logo
#spring
Title
# spring
i

igor.wojda

03/02/2023, 7:45 AM
InteliJ IDEA presents
Could not autowire No beans of "TaskRepository" found
warning in the
UpdateTaskDescriptionUseCase
class (attached image): Here is repo class:
Copy code
@Repository
class TaskRepository {
    // ...
}
The warning seems to be a false positive because the above code works fine (the repo class is injected into the use case) I wonder whats the desired solution is here. Do I need another annotation together with the repo annotation?
d

Davio

03/02/2023, 8:17 AM
Your repository should probably be an interface instead of a concrete class, that's how it usually works
Then Spring can create an implementation for you
t

Ties

03/02/2023, 8:23 AM
Copy code
@Repository
interface TaskRepository : CrudRepository<Long,Task>
would be the typical way to use @Repository It could also be that the TaskRepository is in a completely package than the rest of the application (so the package scan doesnt find it)
j

Jacob

03/02/2023, 2:15 PM
👎 @Repository does not imply a spring data repository. The annotation is in spring core, not spring data. It's perfectly legit to make your own implementation of the repository pattern
👍 1
t

Ties

03/02/2023, 2:22 PM
That's why I included the last bit
7 Views