Não identifica o meu 'med.voll.api.medic.MedicRepository.
obs.: Troquei medico por medic por costume.
Erro: refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'medicController': Unsatisfied dependency expressed through field 'repository': No qualifying bean of type 'med.voll.api.medic.MedicRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 2023-03-31T07:40:23.815-03:00 INFO 21508 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2023-03-31T07:40:23.840-03:00 INFO 21508 --- [ restartedMain] .s.b.a.l.ConditionEvaluationReportLogger :
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled. 2023-03-31T07:40:23.880-03:00 ERROR 21508 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
Field repository in med.voll.api.controller.MedicController required a bean of type 'med.voll.api.medic.MedicRepository' 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 of type 'med.voll.api.medic.MedicRepository' in your configuration.
Process finished with exit code 0
Medic Repository:
package med.voll.api.medic;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface MedicRepository extends JpaRepository<Medic,Long> {
}
MedicController:
package med.voll.api.controller;
import med.voll.api.medic.MedicRepository;
import med.voll.api.medic.Medic;
import med.voll.api.medic.MedicProps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("medicos")
public class MedicController {
@Autowired
private MedicRepository repository;
@PostMapping
public void post(@RequestBody MedicProps data){
repository.save(new Medic(data));
}
}