Boa noite pessoal.
Fiz todo o código igualmente, acredito eu, ao curso e estou com problema para subir a aplicação Alguém consegue me dizer o que estou errando?
#
***
APPLICATION FAILED TO START
***
#
Description:
#
Field repository in br.com.alura.mvc.mudi.controller.HomeController required a bean of type 'repository.PedidoRepository' 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 'repository.PedidoRepository' in your configuration.
#
HomeControleller.java
package br.com.alura.mvc.mudi.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import br.com.alura.mvc.mudi.model.Pedido;
import repository.PedidoRepository;
@Controller
public class HomeController {
@Autowired(required = true)
private PedidoRepository repository;
@GetMapping("/home")
public String home(Model model) {
List<Pedido> pedidos = repository.recuperaTodosOsPedidos();
model.addAttribute("pedidos" , pedidos);
return "home";
}
}
PedidoRepository.java
package repository;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;
import br.com.alura.mvc.mudi.model.Pedido;
@Repository
public class PedidoRepository {
@PersistenceContext
private EntityManager entityManager;
public List<Pedido> recuperaTodosOsPedidos() {
Query query = entityManager.createQuery("Select p from Pedido p", Pedido.class);
return query.getResultList();
}
}