InteliJ IDEA presents `Could not autowire No beans...
# spring
i
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
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
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
👎 @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
That's why I included the last bit
103 Views