I'm getting the following error when using autowire in spring boot
***************************
APPLICATION FAILED TO START
***************************
Description:
Field candidateRepository in io.xgeek.interviewercalendarapi.service.CandidateServiceImpl required a bean of type 'io.xgeek.interviewercalendarapi.repository.CandidateRepository' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean named 'entityManagerFactory' in your configuration.
The autowire, is from the ServiceImpl class, who calls the controller
@Service
public class CandidateServiceImpl implements CandidateService{
@Autowired
private CandidateRepository candidateRepository;
// ... interface methods here...
My repository interface:
@Repository
public interface CandidateRepository extends JpaRepository <Candidate, Long> {
}
Service interface:
public interface CandidateService {
Candidate saveCandidate(Candidate candidate);
List<Candidate> fetchCandidateList();
}
`
Main class: `
@SpringBootApplication
public class InterviewerCalendarApiApplication {
public static void main(String[] args) {
SpringApplication.run(InterviewerCalendarApiApplication.class, args);
}
}
My pom.xml dependecies:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
</dependencies>
I've already try everything. The classes surely are in the correct order, they're inside the packages who are child of the main of the spring boot application. @ComponentScan the packages didn't work.Scan packages didn't work. All the notations appear to be right. I've searched to every questions of this type and I couldn't find a solution.