Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

[Bug] Field repository in med.voll.api.controller.MedicController required a bean of type 'med.voll.api.medic.MedicRepository' that could not be found.

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));
    }
}
1 resposta
solução!

Problema resolvido, era somente um erro no meus proprietes que não achava meu banco sem o jdbc, que resolvi fazendo esse outro erro kkkkj, agora está ok, alterei meu banco para spring.datasource.url=jdbc:mysql://localhost/med_voll e retirei a tag do meu apiAplication @EnableAutoConfiguration, explicando caso alguem teve o mesmo erro que eu.