Alguém teve que lidar com esse erro?
Erro:
APPLICATION FAILED TO START
Description:
Field topicoRepository in br.com.alura.forum.controller.TopicosController required a bean of type 'br.com.alura.forum.repository.TopicoRepository' 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 'br.com.alura.forum.repository.TopicoRepository' in your configuration.
--------classe
package br.com.alura.forum.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.dto.TopicoDto; import br.com.alura.forum.modelo.Topico; import br.com.alura.forum.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);
}
}
-------interface
package br.com.alura.forum.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import br.com.alura.forum.modelo.Topico;
public interface TopicoRepository extends JpaRepository<Topico, Long>{
}
Se eu inserir @ComponentScan("br.com.alura.forum.repository") na classe ForumApplication o projeto compila, mas não consigo acessar /topicos