Bom dia, minha página não está carregando, ao verificar console no Browser, diz o seguinte.
Failed to load resource: the server responded with a status of 405 (Method Not Allowed)
link chamado: http://localhost:8080/agendamento/emails
Application
@ApplicationPath("/") public class AgendamentoEmailApplication extends Application {
}
Controller
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import br.com.alura.entidade.AgendamentoEmail;
import br.com.alura.servico.AgendamentoEmailServico;
@Path("emails")
public class AgendamentoEmailController {
@Inject
private AgendamentoEmailServico agendamentoEmailServico;
@GET
@Produces(value = MediaType.APPLICATION_JSON)
private Response lista() {
return Response.ok(agendamentoEmailServico.listar()).build();
}
@POST
@Consumes(value = MediaType.APPLICATION_JSON)
public Response inserir(AgendamentoEmail agendamentoEmail) {
agendamentoEmailServico.inserir(agendamentoEmail);
return Response.status(201).build();
}
}
SERVICO
import java.util.List;
import javax.ejb.Stateless;
import javax.inject.Inject;
import br.com.alura.dao.AgendamentoEmailDAO;
import br.com.alura.entidade.AgendamentoEmail;
@Stateless
public class AgendamentoEmailServico {
@Inject
private AgendamentoEmailDAO dao;
public List<AgendamentoEmail> listar() {
return dao.listar();
}
public void inserir(AgendamentoEmail agendamentoEmail) {
agendamentoEmail.setAgendado(false);
dao.inserir(agendamentoEmail);
}
}
```