My question is almost identical to this one but not the same, because I'm NOT using Spring Boot.
Can't Autowire @Repository annotated interface in Spring Boot
So I can't do @EnableJpaRepositories
there's no Spring Boot Runner in my case. I have SpringMVC Controllers inside a Web app.
I'm using Spring Data independently, in a regular old-school SpringMVC application.
I'm getting the error
Caused by: No qualifying bean of type 'com.myapp.dao.QuestionsDAO' available:
expected at least 1 bean which qualifies as autowire candidate.
DAO Interface for Spring Data, note @Repository:
@Repository
public interface QuestionsDAO extends JpaRepository<Question, Long> {
public String findById(Long id);
}
A Service should then use this DAO, autowired:
Component
public class SchedulingService {
@Autowired
QuestionsDAO questionsDAO;
public String findLabelById(Long id) {
return questionsDAO.findById(id);
}
}
Component Scan is enabled, works for everything else.
<context:component-scan base-package="com.myapp" />
Is Spring Data only allowed with Spring Boot?