Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

Oie, tive o seguinte erro após criar o Repository

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2021-06-02 21:33:51.574 ERROR 9984 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'topicosController': Unsatisfied dependency expressed through field 'topicoRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'topicoRepository' defined in br.com.alura.forum2021.repository.TopicoRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException

4 respostas

Oi Deborah,

Posta aqui o código da sua interface TopicoRepository.

package br.com.alura.forum2021.repository;

import org.springframework.data.jpa.repository.JpaRepository;

import br.com.alura.forum.modelo.Topico;

public interface TopicoRepository extends JpaRepository<Topico, Long> {

}

package br.com.alura.forum2021.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;

import br.com.alura.forum.modelo.Topico; import br.com.alura.forum2021.controller.dto.TopicoDto; import br.com.alura.forum2021.repository.TopicoRepository;

@RestController public class TopicosController {

@Autowired
private TopicoRepository topicoRepository;


@RequestMapping("/topicos")
public List<TopicoDto>  lista() {

    List<Topico> topicos = topicoRepository.findAll();
    return TopicoDto.converter(topicos);


}

}

solução!

Eu tinha criado o pacote forum. modelo e era para colocar foram2021.modelo, agora foi. Obga!